37

I am using WAMP. I want to use php from the command prompt. What is the entry in PATH env variable for this ?

Boris Guéry
  • 47,316
  • 8
  • 52
  • 87
Bruce
  • 33,927
  • 76
  • 174
  • 262
  • possible duplicate of [Adding directory to PATH Environment Variable in Windows](http://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows) – Abdul Manan Jun 08 '15 at 07:19

7 Answers7

94

You need to add the PHP directory to your path. On the command line (e.g. in a batch file), it would look like this:

SET PATH=%PATH%;C:\your\wamp\path\php

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).

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
21

Follow this for Windows operating system with WAMP installed.

System > Advanced System Settings > Environment Variables
Click new

Variable name  : path
Variable value : c:\wamp\bin\php\php5.3.13\


Click ok
Mukesh
  • 7,630
  • 21
  • 105
  • 159
12

You need to put the directory that has php.exe in you WAMP installation into your PATH. It is usually something like C:\wamp\xampp\php

codaddict
  • 445,704
  • 82
  • 492
  • 529
  • 4
    This answer should elaborately explain or enumerate steps on how to do this on Windows. – Adro Sep 01 '15 at 14:52
  • 5
    @TomasGonzalez, this answere is right. Even if there is no explanation. So there is no reason to downvote. You simply could (A) edit this answere and add some (B) just vote up the answere you prefer (C) use google how to set env-path for your OS or (D) simply ask the writer of this post in his comment to add an explanation! – Dwza May 02 '16 at 08:04
5

For windows: Go to your "system properties" please.then follow as bellow.

Advanced system settings(from left sidebar)->Environment variables(very last option)->path(from lower box/system variables called as I know)->edit

then concatenate the "php" location you have in your pc (usually it is where your xampp is installed say c:/xampp/php)

N.B : Please never forget to set semicolon (;) between your recent concatenated path and the existed path in your "Path"

Something like C:\Program Files\Git\usr\bin;C:\xampp\php

Hope this will help.Happy coding. :) :)

Sakil
  • 983
  • 1
  • 10
  • 18
4

You May use set keyword for set the path

set path=%path%;c:/wamp/bin/php/php5.3.0

if all the path are set in path variables

If you want to see all path list. you can use

set %path%

you need to append your php path behind this path.

This is how you can set environment variable.

Nikunj K.
  • 8,779
  • 4
  • 43
  • 53
2

It depends on your OS, but if you are on Windows XP, you need to go to Systems Properties, then Advanced, then Environment Variables, and include the php binary path to the %PATH% variable.

Locate it by browsing your WAMP directory. It's called php.exe

Boris Guéry
  • 47,316
  • 8
  • 52
  • 87
2

Try display phpinfo() by file and check this var.

Kamilos
  • 795
  • 2
  • 10
  • 25