Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

There are a few similar questions as this throughout the site, but none of them are giving me the answer I'm looking for.

What I'm trying to do is install Composer via Git Bash on a Windows machine that has WAMP.

I'm using the following command:

curl -s http://getcomposer.org/installer | php

This is not working, as 'php' is not recognized. So I looked into the problem and I realized that Windows does not know what 'php' is, and I need to set an environment variable.

I go into the environment variable dialogue and enter 'php' as the variable and C:\wamp\bin\php\php5.3.8 as the value. Is this correct? Should I be targeting a specific file or the directory as a whole?

After doing this, I try the command again and it fails because it still does not recognize 'php'. I have also tried putting the file path into the command directly, but that didn't work either.

So I am curious as to what I am doing incorrectly. Is my path incorrect?

share|improve this question
    
Why on earth are you doing new development using PHP 5.3.8? If you still need PHP 5, at least run 5.6. – Synchro Sep 30 at 13:57
    
This question is 3 years old... 5.6 didn't exist. – ohiock Sep 30 at 18:39
    
Oops! Fair enough! – Synchro Sep 30 at 18:46
up vote 4 down vote accepted

Adding the path to your PATH variable should fix that.

Right click My Computer, go to advanced settings, click Environment Variables then edit the PATH system variable.

Add a semi-colon and then the path to your PHP binary, i.e. ";C:\wamp\bin\php\php5.3.8"

Finally, restart the Git Bash so that it updates the PATH variable.

share|improve this answer

You need to add the PHP directory to your path. On the command line, it would look like this:

SET PATH=%PATH%;C:\wamp\bin\php\php5.5

if in doubt, it's the directory containing the php.exe.

You can also pre-set the path in Windows' control panel. See here on how to do this in Windows 7 for example.

Be aware that if you call the PHP executable from an arbitrary directory, that directory will be the working directory. You may need to adjust your scripts so they use the proper directories for their file operations (if there are any).

share|improve this answer

If you prefer to have it all in the unixy context of your bash cmd window:

  1. Open the bash window and you find by default you're in the root directory

    $ pwd
    /
    
  2. change to your user directory

    $ cd ~
    $ pwd
    /c/Users/nickw
    
  3. create a .bash_profile file or append to an existing one (use single quotes or $PATH will get interpolated)

    $ echo 'PATH=$PATH:/i/wamp64/bin/php/php5.6.19' >> .bash_profile
    
  4. check the file has the entry

    $ cat .bash_profile
    PATH=$PATH:/i/wamp64/bin/php/php5.6.19
    
  5. close the bash window and open a new one to check

    $ php --version
    PHP 5.6.19 (cli) (built: Mar  2 2016 20:09:42)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.