Install Composer in WAMP PHP Google+ Project, PHP not recognized

I follow this PHP Google+ tutorial and I am trying to install the composer in my WAMP directory

C:\wamp\www\gplus-quickstart-php>curl -s https://getcomposer.org/installer | php 

but i get this error

'php' is not recognized as an internal or external command running a program or batch file.

How to solve this problem? I already have PHP installed (via WAMP Server). Should I install PHP on my computer?

+3
php wampserver composer-php
source share
7 answers

Ok a few things you need to do here.

The first windows do not have a curl processor such as unix, so you need to use another option to install Composer

 php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));" 

To do this, you need the php.exe processor to be in your path, so you have 2 options. Either add the folder c:\wamp\bin\php\phpx.yz to your PATH, or my preferred option is to write yourself a small .cmd file that will do it for you like this

 addphp.cmd PATH=%PATH%;c:\wamp\bin\php\phpx.yz 

Place this file in a folder already registered on your path so that you can run it from anywhere in the command window.

Now you will need to edit the file \ wamp \ bin \ php \ phpx.yz \ php.ini. This is similar to the one used by php code running through the Apache web server but only used by the PHP command line CLI interpreter (CLI)

Make sure the php_curl extension is uncommented or the line above does not work, that is, delete the comment character ;

 extension=php_curl.dll 

So, now run the cd command window in the folder where you want to install the composer and execute the command above, and then follow the rest of the installation instructions on the Installation Instructions

+14
source share

In windows, the newly installed composer with the window installer β†’ easy and with the help of a wizard - like him.

https://getcomposer.org/Composer-Setup.exe

+9
source share

I don’t know if anyone will answer this late, but I have problems with this. I created a .cmd file and pasted the path as suggested. I put this file in the wamp \ www \ sitename folder. Isn't that what you mean when you say placing it in the "registered path folder"? After creating the file and running the code, it still says that php is not recognized.

0
source share

first you need to add your php path to the system after switching to php.ini and rmove ; for extension=php_openssl.dll it will be active 3 run this command in cmd:

 php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));" 
0
source share

When installing on Windows, I found the error "Error opening stream" several times. Then I found that this was because the open_ssl extension was disabled (the default in my model).

You can read how to install composer on Wamp here http://codezag.com/how-to-install-composer-wamp/

0
source share

If you use phpstorm, you can download the composer using the composer built into it in the tool menu.

You can run it from the CLI by specifying your php.exe, for example

C:\wamp\bin\php\php7\php.exe composer.phar install

0
source share

Firstly, to get php to your path, see my answer here

The installation of the composer is explained beautifully here (the code below is just for illustration. Be sure to get the latest link)

 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" 

A quick check to confirm that it worked:

  $ php composer.phar --version Composer version 1.2.1 2016-09-12 11:27:19 
0
source share

All Articles