Reputation: 433
On a windows machine, I know that I have to add "c:\path\to\php" into the PATH environment variable. In order that PHP to work from CLI, the cmd window needs to be reopened.
I know that this step is necessary only once, but I'm curios to know if there is a way to have PHP known to cmd window without reopening it.
Upvotes: 1
Views: 361
Reputation: 2282
If I understand you correctly, are you adding the PHP folder to the PATH environment variable every time you open CMD?
To fix this, open Control Panel > System > Advanced System Settings > Environment Variables > look for and highlight the Path variable and click Edit.
Append the PHP folder path (use a semi-colon; to separate different folders) at the end of the path value and Save. You might have to log off and log in again, or restart windows for the changes to take effect.
Another tip: If you want to make PHP scripts executable files, add the *.php extension to the PATHEXEC variable. And be sure that PHP files are opened by the PHP interpreter by default.
Upvotes: 1
Reputation: 17272
You don't have to do this. But if you don't do that, PHP CLI will be "callable" only from the folder where it is installed, so you will have to CD first into the PHP's folder and then launch the PHP. Or call PHP executable with its complete path.
EDIT: You can also change the value of PATH for current session only.
Upvotes: 1