简体   繁体   English

Symfony3:从命令行运行的phpunit返回“'phpunit'未被识别为内部或外部命令,可操作程序或批处理文件。”

[英]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上安装:

  1. Make a directory C:\\bin 制作目录C:\\ bin
  2. Download https://phar.phpunit.de/phpunit-6.1.phar to C:\\bin https://phar.phpunit.de/phpunit-6.1.phar下载到C:\\ bin
  3. Rename the file phpunit.phar 重命名文件phpunit.phar
  4. Open a command prompt and enter the following: 打开命令提示符并输入以下内容:

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.

相关问题 phpunit 从命令行运行返回“'phpunit' 不是内部或外部命令、可运行程序或批处理文件。” - phpunit run from command line returns “'phpunit' is not recognized as an internal or external command, operable program or batch file.” 'symfony' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'symfony' is not recognized as an internal or external command, operable program or batch file 数组(PHP中的数组([0] =>'c:\\ Program'不被识别为内部或外部命令,[1] =>可操作程序或批处理文件。) - Array ( [0] => 'c:\Program' is not recognized as an internal or external command, [1] => operable program or batch file. ) in php 当我在 Windows 上运行 composer 时,我收到一个错误“php.exe”不是内部或外部命令、可运行程序或批处理文件。 - When I run composer on Windows, I get an error of 'php.exe' is not recognized as an internal or external command, operable program or batch file.' 无法将“节点”识别为内部或外部命令,可操作程序或批处理文件。 -Browsershot - 'node' is not recognized as an internal or external command, operable program or batch file. - Browsershot 'git'不被识别为内部或外部命令,可操作程序或批处理文件 - 'git' is not recognized as an internal or external command, operable program or batch file 'C:\\wmic' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'C:\wmic' is not recognized as an internal or external command, operable program or batch file 'bin'不被识别为内部或外部命令,可操作程序或批处理文件 - 'bin' is not recognized as an internal or external command, operable program or batch file 'service' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'service' is not recognized as an internal or external command, operable program or batch file 'Rscript' 不是内部或外部命令,也不是可运行的程序 或批处理文件 - 'Rscript' is not recognized as an internal or external command, operable program or batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM