[英]Symfony3 : phpunit run from command line returns “'phpunit' is not recognized as an internal or external command, operable program or batch file.”
I want to proceed to unit testing on my Symfony3.2 project. 我想对我的Symfony3.2项目进行单元测试。
But 'phpunit' command is not working : when I run phpunit, it returns “'phpunit' is not recognized as an internal or external command, operable program or batch file.” 但是'phpunit'命令不起作用:当我运行phpunit时,它返回“'phpunit'不被识别为内部或外部命令,可操作程序或批处理文件”。
Though, everything seems to be correctly set up. 虽然,似乎一切都已正确设置。 I searched the internet and didn't find anything.
我搜索了互联网,但没有找到任何东西。 So, could somebody help me please ?
那么,有人可以帮我吗?
Follow the instructions from here: 请按照此处的说明进行操作:
https://phpunit.de/manual/current/en/installation.html https://phpunit.de/manual/current/zh/installation.html
从Symfony 3.2开始的新方法是使用phpunit桥,如本博客文章中所述 。
Link only answers are not acceptable on Stackoverflow. 仅链接答案在Stackoverflow上是不可接受的。
Here are the steps to install on Linux: 以下是在Linux上安装的步骤:
wget https://phar.phpunit.de/phpunit-6.1.phar
chmod +x phpunit-6.1.phar
sudo mv phpunit-6.1.phar /usr/local/bin/phpunit
phpunit --version
Verify the version is shown as 6.1.x
and then from your Symfony directory you can now run: 验证版本显示为
6.1.x
,然后从Symfony目录中运行:
phpunit
and your tests should run. 并且您的测试应该运行。
EDIT #2 编辑#2
Based on feedback from Cerad. 根据Cerad的反馈。 Use these commands to install on windows:
使用以下命令在Windows上安装:
cd C:\bin
echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
Then you can enter: 然后您可以输入:
phpunit --version
and you should see the version shown. 并且您应该看到显示的版本。 Also you need to add
C:\\bin
to your environment PATH. 另外,您需要将
C:\\bin
添加到环境PATH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.