I use the WAMP stack to write my PHP applications and PHP modules for Prestashop. As many engineers I use Windows. Recently I needed to run PHP from the command line. You will learn in this blogpost how I added PHP to Windows Path variable to let Windows know where PHP is deployed.
Start a new folder and navigate to computer. The easier way to achieve this is to run the shortcut Windows + E. Other GUI-based solutions are available but may vary according to your operating system version (Windows 7, Windows 10).
Once you bring the Computer Window, hit the button System Properties on the left hand side of the navigation menu. You get the new System properties Window.
On the System properties Window, look at the control panel menu on the left. Hit the last button so called Advanced System settings.
In the Advanced system settings window hit the button Environment Variables…
In the Environment Variables window select the path in the user variables section and hit the button Edit…
In the Edit User Variable window, move the cursor to the end of the content. Then append the location of PHP to the original content. For WAMP installation, PHP is located in C:\wamp64\bin\php\php.X.Y.Z where X.Y.Z matches to the version of PHP that you are running.
After you have entered the location of PHP, save it, then restart your command prompt.
From now on, you can run PHP from the command prompt on your Windows computer. It is quite handy when you are developing Symfony based application.
In this short tutorial, you learnt about how to add PHP to Windows Path variable. It applies to Windows 7, Windows 8 or Windows 10!
Enjoy your code writing session.