How to add your PHP runtime directory to your Windows 10 PATH environment variable

Today I will explain how to add your PHP runtime directory to your Windows 10 PATH
environment variable.
This will give you global access to php.exe
from any command prompt.
Please note that you must reopen your command prompt windows (if you had any open prior to the update).
Command prompt loads the PATH
environment variable when it is first open.
Target audience
- Windows 10 users
- PHP developers that want PHP to be globally accessible from any command prompt (ex.: php.exe for “linting” or to start a dev. server)
Note that you are not limited to PHP, this can be any directory containing any program - ex.: npm
How to
Copy shortcut:
ctrl+C
Paste shortcut:ctrl+V
- Find your PHP installation directory and copy it somewhere (your clipboard is a good place)
- For MAMP users it will be something like
C:\MAMP\bin\php\php5.6.21
(the PHP version may vary).
- For MAMP users it will be something like
- Right-click on the “Start menu”
- Click “System”
- Click “Advanced system settings”
- Click “Environment Variables…”
- Select the “Path” variable (in your user or in the system list)
- Click “Edit…”
- Click “New”
- Paste your PHP path
- Click OK
- Click OK
- Click OK
- Close your “system window”
And voilĂ !
How to test if it worked out
- Open a command prompt
- Right-click on the start menu
- Click “Command Prompt” or “Command Prompt (admin)”
- In the command prompt, type
php -?
If it displays PHP help then it worked!