如何使用Composer安装Symfony2捆绑软件 [英] How to install Symfony2 Bundles with Composer
问题描述
我正在使用Windows,并且从Windows安装程序安装了composer。我想要做的是将 DoctrineMigrationsBundle 安装到我的项目中,所以我
I'm using Windows and I installed composer from its Windows installer. What I want to do is to install DoctrineMigrationsBundle to my project, so I added
doctrine / doctrine-migrations-bundle:开发大师
到项目中的 composer.json
文件并运行
cd the project directory
php composer.phar update
但是我得到的是:无法打开输入文件:composer.phar
but what I get is: Could not open input file: composer.phar
我的整个composer.json文件是
My whole composer.json file is
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.1.*",
"twig/extensions": "1.0.*@dev",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
"symfony/monolog-bundle": "2.1.*",
"sensio/distribution-bundle": "2.1.*",
"sensio/framework-extra-bundle": "2.1.*",
"sensio/generator-bundle": "2.1.*",
"jms/security-extra-bundle": "1.2.*",
"jms/di-extra-bundle": "1.1.*",
"kriswallsmith/assetic": "1.1.*@dev"
"doctrine/doctrine-migrations-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
}
}
可以吗
推荐答案
正如@AhmedSiouani所说,该错误告诉您他们找不到 composer.phar
文件。
As said by @AhmedSiouani, the error tells you that they can't find a composer.phar
file.
您可以执行以下操作:
- 下载
Composer-SetUp.exe
并按照下载页面上的说明进行安装(滚动到 Windows Installer); - 下载
composer.phar
文件并将其放入您的项目中(不推荐); - 下载
composer.phar
文件,并将其放在您的PATH
环境变量 1 中的目录中; -
下载
composer.phar
文件并创建composer.bat
文件,该文件执行composer.phar
文件。将下面的代码放入其中,并将其保存在您的PATH
环境变量 1 中的目录中。
- Download the
Composer-SetUp.exe
and install Composer as told on the downloads page (scroll to 'Windows Installer'); - Download the
composer.phar
file and put that in your project (not recommend); - Download the
composer.phar
file and put that in a directory which is in yourPATH
environment variable1; Download the
composer.phar
file and create acomposer.bat
file which executes thecomposer.phar
file. Put the code below in it and save it in a directory which is in yourPATH
environment variable1.
@echo off
php "path\to\composer.phar" %*
1 :您可以看到
在您的cmd中运行 echo%PATH%
,在 PATH
环境变量中包含哪些目录。
您还可以将该文件所在的目录放在 PATH
环境中。为此,请转到 计算机
(右键单击)> 设置
> 高级设置
> 环境变量
(在高级标签下),并使用目录路径设置PATH变量(或添加路径通过在路径之间放置;
到当前PATH变量)。
1: You can see which directories are in the PATH
environment variable by
running echo %PATH%
in your cmd.
You can also put the directory where this file lives in the PATH
environment. To do that, go to Computer
(right click) > Settings
> Advanced Settings
> Environments Variables
(under the 'advanced' tab) and set the PATH variable with your directory path (or add the path to the current PATH variable, by putting a ;
between the paths).
这篇关于如何使用Composer安装Symfony2捆绑软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!