windows 从命令行运行 phpunit 返回“'phpunit' 不是内部或外部命令,也不是可运行的程序或批处理文件。”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6278418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:01:13  来源:igfitidea点击:

phpunit run from command line returns "'phpunit' is not recognized as an internal or external command, operable program or batch file."

phpwindowswindows-7phpunit

提问by Will

When I run phpuniton the command line I get 'phpunit' is not recognized as an internal or external command, operable program or batch file.

当我phpunit在命令行上运行时,我得到'phpunit' is not recognized as an internal or external command, operable program or batch file.

php has been added to my system path. My php.ini includes include_path=".;C:\PHP\pear".

php 已添加到我的系统路径中。我的 php.ini 包括include_path=".;C:\PHP\pear".

How can I get the command phpunit to be recognized by the command line?

如何让命令行识别命令 phpunit?

回答by Gordon

Make sure your PEAR installation is installed properlyand available in the Windows environment. Each PEAR command has a corresponding .bat file in the PEAR installation directory, e.g. phpunit.bat. Because these are the files that get called when doing e.g. phpunit on the command line, this directory has to be on your PATH as well. Having the PEAR directory on the include_path only is not enough.

确保您的PEAR 安装正确安装并且在 Windows 环境中可用。每个 PEAR 命令在 PEAR 安装目录中都有一个对应的 .bat 文件,例如 phpunit.bat。因为这些是在命令行上执行例如 phpunit 时被调用的文件,所以该目录也必须在您的 PATH 上。仅在 include_path 上拥有 PEAR 目录是不够的。

If you are sure PEAR is installed properly. reinstall PHPUnit with

如果您确定 PEAR 安装正确。重新安装 PHPUnit

pear install --alldeps --force phpunit/PHPUnit 

回答by LazyOne

You need to add php path (which is C:\PHP) to the PATH variable.

您需要将 php 路径(即 C:\PHP)添加到 PATH 变量中。

On Windows 7 it will be: 1) My Computer -> Right click -> Properties 2) Advanced System Settings 3) Click "Environment variables" button 4) Find "Path" entry in "System variable" section and: a) add to the end ";C:\PHP" (without quotes) or b) add to the front "C:\PHP;"

在 Windows 7 上,它将是:1) 我的电脑 -> 右键单击​​ -> 属性 2) 高级系统设置 3) 单击“环境变量”按钮 4) 在“系统变量”部分中找到“路径”条目,然后:a) 添加到末尾的“;C:\PHP”(不带引号)或 b) 添加到前面的“C:\PHP;”

EDIT:

编辑:

php has been added to my system path.

php 已添加到我的系统路径中。

You doneed to open a new windows command prompt (no need for logoff, restart...)

确实需要打开一个新的 Windows 命令提示符(无需注销、重新启动...)