Like many developers, I write code on my local machine. WAMP is my tool of choice as the majority of my projects are PHP based. Certain situations require me to run PHP tasks from the Windows command prompt (ie: reindexing Magento databases). In order to run PHP from the command prompt in Windows, you need to tell Windows where PHP is located by adding its location to your Windows Path variable. Let’s do it.
-
Click the Start menu orb and go to Computer.
-
In the Computer window click the System properties button on navigation bar.
-
In the System properties window click the Advanced system settings link.
-
In the Advanced system settings window click the Environment Variables… button.
-
In the Environment Variables window select the path in the user variables section and click the Edit… button.
Environment Variables -
In the Edit User Variable window place your cursor at the end of the contents within the Variable value: input and add the location of PHP to that string. In a typical WAMP installation, PHP is located in
C:\wamp\bin\php\php.#.#.#
where #.#.# corresponds to the version of PHP that you are running.Note: locations are separated by semicolons. So, make sure there is a semicolon before you define the location of PHP in the variable value.
-
After you have entered the location of PHP, click the OK button and restart your command prompt. Congrats, you can now run PHP from the Windows command prompt!
Comments