无论我在哪个目录中,如何在 Windows 命令行中运行 phpunit 命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2182304/
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
How do I run phpunit command in Windows command line no matter what directory I am in?
提问by yretuta
all examples of phpunit I saw run the simple command line tool:
我看到的所有 phpunit 示例都运行了简单的命令行工具:
phpunit TestClass
phpunit 测试类
but when I try the same on a directory other than the xampp php dir, I end up getting an "unknown command..."
但是当我在 xampp php 目录以外的目录上尝试相同的操作时,我最终得到一个“未知命令......”
Is there a way to execute the phpunit command from any directory in the Windows command line?
有没有办法从 Windows 命令行中的任何目录执行 phpunit 命令?
回答by Yada
Add the phpunit to your System PATH
将 phpunit 添加到您的系统路径
Setting Path on Windows Start -> Control Panel -> System -> Advanced Click on Environment Variables, under System Variables, find PATH, and click on it. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value. Close the window. Reopen Command prompt window, and run phpunit TestClass
在Windows上设置路径开始->控制面板->系统->高级点击Environment Variables,在System Variables下找到PATH,点击它。在编辑窗口中,通过将类的位置添加到 PATH 的值来修改 PATH。如果您没有 PATH 项,您可以选择添加一个新变量并添加 PATH 作为名称和类的位置作为值。关闭窗口。重新打开命令提示符窗口,并运行 phpunit TestClass