开发者

How to do a proper setup for CLI of PHP

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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜