46

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

dylan-myers
  • 323
  • 3
  • 18
Sundar
  • 4,580
  • 6
  • 35
  • 61

16 Answers16

104

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

Dorjee Dhondup
  • 549
  • 6
  • 15
Kamesh Jungi
  • 6,203
  • 6
  • 39
  • 50
34

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

Kacper Cieluch
  • 437
  • 3
  • 16
Sundar
  • 4,580
  • 6
  • 35
  • 61
28

I was trying to install 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

Then i gave the full path of .phar like this:

php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha

and it worked.

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59
Atta Ur Rehman
  • 476
  • 5
  • 9
  • composer create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha or php composer create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha – Sundar Jan 23 '14 at 05:04
  • I was typing the `composer create-project -sdev zendframework/skeleton-application path/to/install`command seen at `https://github.com/zendframework/ZendSkeletonApplication` but it would give me the error message `Could not open input file: /home/stephane/programs/laravel-5.1.1/composer.phar`. So I tried with your syntaxt `php composer.phar create-project -s dev zendframework/skeleton-application ...`and it worked fine. – Stephane Oct 26 '16 at 15:48
13

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.

DarkSpirit
  • 307
  • 1
  • 3
  • 6
  • Had same problem but had to Additionally "cd" to the location where the composer.json file is located – nodws Jan 28 '21 at 03:03
8

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.

6

Question already answered by the OP, but I am posting this answer for anyone having similar problem, retting to

Could not input open file: 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:

/Library/WebServer/Documents/zendframework

change directory to it, and then run composer update.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
5

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.

kta
  • 19,412
  • 7
  • 65
  • 47
5

Try in command line:

curl -sS https://getcomposer.org/installer | php
Zoe
  • 27,060
  • 21
  • 118
  • 148
  • This worked for me after I botched uninstalling composer. .... 1. curl -sS https://getcomposer.org/installer | php .... then 2. mv composer.phar /usr/local/bin/ – Adam Nov 25 '21 at 19:34
4

dont use php composer.phar self-update
First go to Your project directory
simply use composer.phar self-update
This works for me

Rajesh Patel
  • 1,946
  • 16
  • 20
4

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

Anoop Saini
  • 307
  • 3
  • 5
  • In principal the instructions here work. However the latest version is slightly different. Reference: https://getcomposer.org/download/ – Ron Piggott Feb 11 '19 at 05:13
3

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.

Community
  • 1
  • 1
Imnotapotato
  • 5,308
  • 13
  • 80
  • 147
3

If you go through the documentation, they have mentioned to use php composer.phar Link: https://getcomposer.org/doc/03-cli.md#update-u

Don't use php composer.phar only give composer

Command: composer self-update

It will work.

Erielama
  • 51
  • 1
  • 5
2

Instead of

php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application path/to/install

use

php composer.phar create-project --repository-url="https://packages.zendframework.com" zendframework/skeleton-application path/to/install

Just add https instead of http in the URL. Though it's not a permanent solution, it does work.

Dharman
  • 30,962
  • 25
  • 85
  • 135
user1052478
  • 129
  • 1
  • 3
2

Another solution could be.. find the location of composer.phar file in your computer. If composer is installed successfully then it can be found in the installed directory.

Copy that location & instead of composer.phar in the command line, put the entire path there.

It also worked for me!

user1052478
  • 129
  • 1
  • 3
2

Just Use composer install

composer install
Sandeep Sherpur
  • 2,418
  • 25
  • 27
1

I had the same issue when trying to use php composer install in a local directory on my Apache server for a laravel project I cloned from Github. My problem was I had already setup composer globally on my Ubuntu 18 machine.
Adding sudo instead of php started the install of a whole slew of packages listed in the json.lock file i.e. sudo composer install.

Hmerman6006
  • 1,622
  • 1
  • 20
  • 45