php 无法打开输入文件:composer.phar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20769980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not open input file: composer.phar
提问by Sundar
I am trying to install zendframeworkusing composer tool in wamp server.
我正在尝试在 wamp 服务器中使用 composer 工具安装zendframework。
The following steps are done towards installation
完成以下步骤进行安装
I downloaded the Composer-Setup.exe file from composer page and got successfully installed.
I downloaded the zendframeworkand extracted inside the
c:\wamp\www\zendfolderI executed the command for self update
php composer.phar self-update
我从作曲家页面下载了 Composer-Setup.exe 文件并成功安装。
我下载了zendframework并解压到
c:\wamp\www\zend文件夹中我执行了自我更新的命令
php composer.phar self-update
This line generates the error message: could not open file composer.phar
此行生成错误消息: could not open file composer.phar
how to resolve this error
如何解决这个错误
If I try the
如果我尝试
composer.phar self-update


采纳答案by Sundar
The composer.phar install is not working but without .phar this is working.
composer.phar 安装不工作,但没有 .phar 这是工作。
We need to enable the openssl module in php before installing the zendframe work.
在安装zendframe工作之前,我们需要在php中启用openssl模块。
We have to uncomment the line ;extension=php_openssl.dllfrom php.inifile.
我们必须从文件中取消注释;extension=php_openssl.dll行php.ini。
composer use different php.ini file which is located at the wamp\bin\php\php-<version number>\php.ini
composer 使用不同的 php.ini 文件,该文件位于 wamp\bin\php\php-<version number>\php.ini
After enabling the openssl we need to restart the server.
启用 openssl 后,我们需要重新启动服务器。
The execute the following comments.
执行以下注释。
I can install successfully using these commands -
我可以使用这些命令成功安装 -
composer self-update
composer install --prefer-dist


回答by Kamesh Jungi
Use this :
用这个 :
php -r "readfile('https://getcomposer.org/installer');" | php
This will install composer to the current directory so that you can use php composer.phar
这会将 composer 安装到当前目录,以便您可以使用 php composer.phar
回答by Atta Ur Rehman
I was trying to install YII 2.0
我试图安装 YII 2.0
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha
I got the same error:
我得到了同样的错误:
Could not open input file: composer.phar
无法打开输入文件:composer.phar
Then i gave the full path of .phar like this:
然后我给出了 .phar 的完整路径,如下所示:
php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha
and it worked.
它奏效了。
回答by DarkSpirit
I am using Windows 7, and I got the same problem as yours while using Composer via cmd.
我使用的是 Windows 7,在通过 cmd 使用 Composer 时遇到了与您相同的问题。
The problem is solved when I use
当我使用时问题解决了
php C:\ProgramData\ComposerSetup\bin\composer.phar create-project slim/slim-skeleton
instead of
代替
php composer.phar create-project slim/slim-skeleton
Hope this is useful for people who got the same problem.
希望这对遇到同样问题的人有用。
回答by Michael Sebastian
First try this: dont use the php composer.phar [parameters]simply use composer [parameters]if this doesn't work for you than try the rest. Hope it helps.
首先尝试这个:如果这对你不起作用,不要使用php composer.phar [parameters]简单的使用composer [parameters],而不是尝试其余的。希望能帮助到你。
回答by kta
Initially, I was running php composer.phar self-update and got the same error message.
最初,我正在运行 php composer.phar self-update 并收到相同的错误消息。
As a resolve, you should use composer command directly after install it.From the command prompt, just type composer and press enter.
作为解决方案,您应该在安装后直接使用 composer 命令。在命令提示符下,只需键入 composer 并按回车键即可。
If composer is installed correctly then you should able to see a lot of suggestion and command list from composer.
如果 Composer 安装正确,那么您应该能够从 Composer 看到很多建议和命令列表。
If you are up to this point then you should able to run composer self-update directly.
如果您到此为止,那么您应该能够直接运行 composer self-update。
回答by Pmpr
Question already answered by the OP, but I am posting this answer for anyone having similar problem, retting to
问题已经由 OP 回答,但我将这个答案发布给任何有类似问题的人,重新发布
Could not input open file: composer.phar
无法输入打开的文件:composer.phar
error message.
错误信息。
Simply go to your project directory/folder and do a
只需转到您的项目目录/文件夹并执行
composer update
Assuming this is where you have your web application:
假设这是您拥有 Web 应用程序的地方:
/Library/WebServer/Documents/zendframework
change directory to it, and then run composer update.
将目录更改为它,然后运行composer update.
回答by Anoop Saini
I have fixed the same issue with below steps
我已经通过以下步骤解决了同样的问题
- Open project directory Using Terminal (which you are using i.e. mintty)
- Now install composer within this directory as per given directions on https://getcomposer.org/download/
- 使用终端打开项目目录(您正在使用即 mintty)
- 现在按照https://getcomposer.org/download/ 上的给定说明在此目录中安装 composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'the-provided-hash-code') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php php -r "unlink('composer-setup.php');"
php -r "copy(' https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'the-provided-hash-code') { echo '安装程序已验证'; } else { echo '安装程序损坏'; 取消链接('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php php -r "unlink('composer-setup.php');"
- Now run your command.
- 现在运行你的命令。
Everything is working fine now because the composer.pharfile is available within the current project directory.
现在一切正常,因为该composer.phar文件在当前项目目录中可用。
Copied from https://stackoverflow.com/questions/21670709/running-composer-returns-could-not-open-input-file-composer-phar/51907013#51907013
thanks
谢谢
回答by Rajesh Patel
dont use php composer.phar self-update
First go to Your project directory
simply use composer.phar self-update
This works for me
不要使用php composer.phar self-update
首先转到您的项目目录
只需使用composer.phar self-update
这对我有用
回答by Rick Sanchez
This is how it worked for me:
这就是它对我的工作方式:
Make sure composer is installed without no errors.
Open "System Properties" on windows and go to the "Advanced" tab. (You can just press the windows button on your keyboard and type in "Edit the system environment variables`
"Environment variables"
Under "System variables" Edit "PATH"
Click on "New".
Type in: C:\ProgramData\ComposerSetup\bin\composer.phar
Close all folders & CMDs + restart you WAMP server.
Go to whatever directory you want to install a package in and type in
composer.phar create-project slim/slim-skeleton
确保 Composer 安装没有错误。
在 Windows 上打开“系统属性”并转到“高级”选项卡。(您只需按下键盘上的 Windows 按钮并输入“编辑系统环境变量”
“环境变量”
在“系统变量”下编辑“PATH”
点击“新建”。
输入:C:\ProgramData\ComposerSetup\bin\composer.phar
关闭所有文件夹和 CMD + 重新启动 WAMP 服务器。
转到您要安装软件包的任何目录并输入
composer.phar create-project slim/slim-skeleton
for example.
例如。

