[英]PHP is not recognized as an internal or external command in command prompt
I got the following error when I run a command with php
当我使用
php
运行命令时出现以下错误
C:\xampp\htdocs>php
'php' is not recognized as an internal or external command,
operable program or batch file.
I don't get any error when I run the command with php
in following path:当我在以下路径中使用
php
运行命令时,我没有收到任何错误:
C:\xampp\php>php //do not got error here
Why I get this error?为什么我会收到此错误?
'php' is not recognized as an internal or external command, operable program or batch file.
'php' 不是内部或外部命令,也不是可运行的程序或批处理文件。
Add C:\\xampp\\php
to your PATH
environment variable.( My Computer->properties -> Advanced system setting-> Environment Variables->edit path )将
C:\\xampp\\php
添加到您的PATH
环境变量中。(我的电脑->属性->高级系统设置->环境变量->编辑路径)
Then close your command prompt and restart again.然后关闭命令提示符并再次重新启动。
Note: It's very important to close your command prompt and restart again otherwise changes will not be reflected.注意:关闭命令提示符并重新启动非常重要,否则将不会反映更改。
You need to Go to My Computer->properties -> Advanced system setting您需要转到我的电脑-> 属性-> 高级系统设置
Now click on Environment Variables..现在点击环境变量..
Add ;C:\\xampp\\php in path variable value在路径变量值中添加;C:\\xampp\\php
Now restart command prompt DONE!现在重新启动命令提示符完成!
Note: Make sure you run CMD via run as administrator注意:确保以管理员身份运行 CMD
Set "C:\\xampp\\php"
in your PATH Environment Variable .在 PATH Environment Variable 中设置
"C:\\xampp\\php"
。 Then restart CMD prompt.然后重新启动 CMD 提示。
Is your path correctly configured?你的路径配置正确吗?
In Windows, you can do that as described here:在 Windows 中,您可以按照此处所述进行操作:
http://www.computerhope.com/issues/ch000549.htm http://www.computerhope.com/issues/ch000549.htm
您需要将C:\\xampp\\php
添加到您的PATH Environment Variable
,只有在此之后您才能从php_home
外部执行php
命令行。
I also got the following error when I run a command with PHP
, I did the solution like that:当我使用
PHP
运行命令时,我也遇到了以下错误,我是这样解决的:
C:\\xampp\\php
to your PATH Environment Variable.C:\\xampp\\php
添加到您的PATH环境变量。 Very important note: restart command prompt非常重要的提示:重启命令提示符
Here what I DO on MY PC I install all software that i usually used in G: partian not C: if my operating system is fall (win 10) , Do not need to reinstall them again and lost time , Then How windows work it update PATH automatic if you install any new programe or pice of softwore ,这是我在我的 PC 上所做的,我安装了我通常在 G 中使用的所有软件:partian 而不是 C:如果我的操作系统失败(win 10),不需要再次重新安装它们并浪费时间,那么 Windows 是如何工作的呢?如果您安装任何新程序或软件,路径自动,
SO所以
I must update PATH like these HERE!我必须在这里更新 PATH ! all my software i usually used
我常用的所有软件
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;G:\HashiCorp\Vagrant\bin;G:\xampp\php;G:\xampp\mysql\bin;G:\Program Files (x86)\heroku\bin;G:\Program Files (x86)\Git\bin;G:\Program Files (x86)\composer;G:\Program Files (x86)\nodejs;G:\Program Files (x86)\Sublime Text 3;G:\Program Files (x86)\Microsoft VS Code\bin;G:\Program Files (x86)\cygwin64\bin
Extra info:额外信息:
If you are using PhpStorm as IDE, after updating the path variable you need to restart PhpStorm so that it takes effect.如果你使用 PhpStorm 作为 IDE,更新路径变量后需要重启 PhpStorm 才能生效。
Restarting terminal window was not enough for me.重新启动终端窗口对我来说还不够。 (PhpStorm 2020.3.2)
(PhpStorm 2020.3.2)
I faced this issue even with a properly set up windows environment variable.即使正确设置了 Windows 环境变量,我也遇到了这个问题。 I just needed to close and restart the terminal to solve it.
我只需要关闭并重新启动终端来解决它。
The previous answers about adding the path to the Env Var are correct, but my case was different.之前关于将路径添加到 Env Var 的答案是正确的,但我的情况不同。
I needed to downgrade my PHP version to 5 in order to update an old application.我需要将我的 PHP 版本降级到 5 才能更新旧应用程序。
I was using the following combination: MAMP, PhpStorm, the Environment Variable Path was set properly to the MAMP PHP version that I was using我使用了以下组合:MAMP、PhpStorm,环境变量路径已正确设置为我使用的 MAMP PHP 版本
Laragon users<\/strong> Laragon 用户<\/strong>
you will find your PHP folder in the bin folder of laragon.你会在 laragon 的 bin 文件夹中找到你的 PHP 文件夹。 goto your desired PHP version folder and copy the location.
转到您想要的 PHP 版本文件夹并复制该位置。 for me it was:
对我来说是:
C:\laragon\bin\php\php-7.4.19-Win32-vc15-x64
在我的情况下,问题出在路径中,我给出了php.exe<\/code>的路径,这是错误的,我必须编写根文件夹的路径......
"
For Laragon:对于拉拉贡:
First, download your PHP from [https:\/\/windows.php.net\/download\/] then unzip your file -> copy folder -> paste this direction:首先,从 [https:\/\/windows.php.net\/download\/] 下载您的 PHP,然后解压缩您的文件 -> 复制文件夹 -> 粘贴此方向:
C:\\laragon\\bin\\php`Your folder` C:\\laragon\\bin\\php`你的文件夹`
search from windows从窗口搜索
Edit the system environment variables and then open it.编辑系统环境变量,然后打开它。
<\/a>
<\/blockquote>
Click Environment variables...单击环境变量...
<\/a>
and then press OK for all steps.然后按 OK 执行所有步骤。
restart laragon and vscode重启 laragon 和 vscode
and our problem is already solved.我们的问题已经解决了。
"
In latest Xampp 8.1.2 PHP path is changed to this below: Set it in your PATH variable.在最新的 Xampp 8.1.2 PHP 路径更改为以下内容: 在 PATH 变量中设置它。
C:\xampp\php\windowsXamppPhp
I restarted CMD program it solves my problem我重新启动了 CMD 程序,它解决了我的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.