How to set the env variable for PHP?
Asked Answered
H

8

40

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

Hairdresser answered 29/4, 2010 at 10:26 Comment(1)
possible duplicate of Adding directory to PATH Environment Variable in WindowsPietra
R
13

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

Ranger answered 29/4, 2010 at 10:29 Comment(2)
This answer should elaborately explain or enumerate steps on how to do this on Windows.Lewin
@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!Busoni
K
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).

Ky answered 29/4, 2010 at 10:31 Comment(1)
this one help to set but I need set every time when start cmd. is there any permanent solution using CMD ?Irena
C
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
Chamberlin answered 24/3, 2014 at 11:3 Comment(0)
R
13

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

Ranger answered 29/4, 2010 at 10:29 Comment(2)
This answer should elaborately explain or enumerate steps on how to do this on Windows.Lewin
@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!Busoni
M
6

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

Malpighiaceous answered 4/6, 2016 at 17:13 Comment(0)
I
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.

Interpreter answered 2/10, 2013 at 13:34 Comment(0)
M
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

Melodize answered 29/4, 2010 at 10:29 Comment(0)
S
2

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

Syneresis answered 29/4, 2010 at 10:33 Comment(0)
P
0

You have to follow the below steps to add php as a variable in Windows.

  1. Type 'env' in start bar and press Enter.(Edit environment variables for your account')
  2. Goto the 'Environment Variables...' button under 'Startup and Recovery' section.
  3. Goto the 'System variables' and find 'Path' row.
  4. Select it and press 'Edit' button.
  5. Select 'New' button and select 'Edit'.
  6. After that you wan to add the location of where the php folder is in. (select the folder and press 'OK')
  7. Then close every window by pressing 'OK' buttons until 'System Properties' window close.
  8. Then restart your machine.

Now you are good to go.

Presumption answered 29/1 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.