Could not open input file: composer.phar

2019-01-13 02:35发布

I am trying to install zendframework using composer tool in wamp server.

The following steps are done towards installation

  1. I downloaded the Composer-Setup.exe file from composer page and got successfully installed.

  2. I downloaded the zendframework and extracted inside the c:\wamp\www\zend folder

  3. I executed the command for self update

    php composer.phar self-update

This line generates the error message: could not open file composer.phar

how to resolve this error

If I try the

composer.phar self-update

enter image description here

10条回答
Emotional °昔
2楼-- · 2019-01-13 02:57

I am using Windows 7, and I got the same problem as yours while using Composer via cmd.

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.

查看更多
该账号已被封号
3楼-- · 2019-01-13 02:59

Initially, I was running php composer.phar self-update and got the same error message.

As a resolve, you should use composer command directly after install it.From the command prompt, just type composer and press enter.

If composer is installed correctly then you should able to see a lot of suggestion and command list from composer.

If you are up to this point then you should able to run composer self-update directly.

查看更多
Evening l夕情丶
4楼-- · 2019-01-13 02:59

I have fixed the same issue with below steps

  1. Open project directory Using Terminal (which you are using i.e. mintty )
  2. Now install composer within this directory as per given directions on https://getcomposer.org/download/

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');"

  1. Now run your command.

Everything is working fine now because the composer.phar file is available within the current project directory.

Copied from https://stackoverflow.com/questions/21670709/running-composer-returns-could-not-open-input-file-composer-phar/51907013#51907013

thanks

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-13 03:03

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

for example.

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-01-13 03:08

The composer.phar install is not working but without .phar this is working.

We need to enable the openssl module in php before installing the zendframe work.

We have to uncomment the line ;extension=php_openssl.dll from php.ini file.

composer use different php.ini file which is located at the wamp\bin\php\php-<version number>\php.ini

After enabling the openssl we need to restart the server.

The execute the following comments.

I can install successfully using these commands -

composer self-update
composer install --prefer-dist

enter image description here

查看更多
We Are One
7楼-- · 2019-01-13 03:09

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

查看更多
登录 后发表回答