Skip to main content

Running PHP by command line on WAMP

There are a few simple steps one can follow to run php scripts by command line.

Usually if you write "php" on the DOS prompt it will not recognize the command. In order to run php on command line in windows you have to do the following -
Step 1 : Go to your wamp directory:\wamp\bin\php\php5.x.x (directory depends on your version). Copy this path

Step 2 : Right click on My Computer and go to properties > Advanced > Environment Variables > System Variables . In that window select "path" click edit button. Go to the end of "Variable Value" and add a semi-colon ";" and after that paste the path copied. Click "Ok" and close.
Step 3 : Open a fresh command prompt . Type php. Now it should run.

Comments

  1. Thanks! I spent more time than I care to admit before finally finding you.
    jerryLee
    http://seointexas.com

    ReplyDelete
  2. Thank you for this post. The keywords that made it work for me was "fresh command prompt"... stupid me.

    ReplyDelete
  3. its not working for me . i done the same thing what u told . i am geting a error php not recognized .

    ReplyDelete
  4. Not working for me on Windows 7. Strangely if I install php separately in for example c:\php, then all is fine, but the WAMP server doesn't start successfully, which renders this workaround useless.

    ReplyDelete
  5. Thanks. Was searching for this on google

    ReplyDelete

Post a Comment