WAMP:“'php' 未被识别为内部或外部命令可操作程序或批处理文件”,尽管添加了 PATH

WAMP: "'php' is not recognized as an internal or external command operable program or batch file" although adding PATH

当我在 CMD 中 运行 PHP 时收到此错误消息:

'php' is not recognized as an internal or external command operable program or batch file

路径已经添加,我遵循了本教程:

http://perials.com/install-composer-on-windows-and-wamp/

C:\Program Files (x86)\Lenovo\FusionEngine;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Lenovo\Motion Control\;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\; C:\wamp\bin\php\php5.5.12; C:\wamp\www; C:\wamp\www\AKP\examples\AdWords\Auth;C:\Program Files (x86)\Skype\Phone\;C:\ProgramData\ComposerSetup\bin

我创建了 post 中建议的文件: Installing Composer globally for laravel usage?

什么也没有。

我 运行 中的大多数 post 都通过添加路径解决了问题 - 这并没有解决我的问题。

我目前正在 Windows 10 上使用 WAMP。

可能是什么问题?

我不太明白你说 Windows 10 显示 %20 是什么意思,但错误消息说你在 PATH 中没有任何 php 程序,这就是问题所在。路径目录不区分大小写(这就是 Windows 设计的工作方式)但空格很重要:

C:\>PATH C:\WINDOWS;C:\PHP

C:\>php -v
PHP 5.6.15 (cli) (built: Oct 29 2015 12:40:36)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

C:\>PATH C:\WINDOWS; C:\PHP

C:\>php -v
"php" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

C:\>PATH C:\PHP ;C:\WINDOWS

C:\>php -v
"php" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

即使 Windows 10 更改了 PATH 处理以修复一些常见错误(我现在无法测试)我认为逐字输入正确的路径更简单。

PHP 未包含在您的 PATH 中。右键单击您的“我的电脑”,然后单击“属性”、“高级系统设置”、“环境变量”,然后找到 PATH 变量,将您的 PHP 安装目录添加到那里。关闭您之前启动的 CMD,重新启动它,它现在应该可以工作了。

如果您使用的是 xampp,则搜索环境变量 > 单击环境变量 > 系统变量 > PATH > 编辑 > 新建 > 复制粘贴 xampp 的位置用于 windows C:\xampp\php 然后你可以用命令 php -v

检查 php 版本