我正在按照这些说明操作:
Windows Globally installing the PHAR involves the same procedure as manually installing Composer on Windows:
Create a directory for PHP binaries; e.g., C:\bin
Append ;C:\bin to your PATH environment variable (related help)
Download https://phar.phpunit.de/phpunit-6.2.phar and save the file as C:\bin\phpunit.phar
Open a command line (e.g., press Windows+R » type cmd » ENTER)
Create a wrapping batch script (results in C:\bin\phpunit.cmd):
C:\Users\username> cd C:\bin C:\bin> echo @php "%~dp0phpunit.phar" %*
phpunit.cmd C:\bin> exit Open a new command line and confirm that you can execute PHPUnit from any path:
C:\Users\username> phpunit --version PHPUnit x.y.z by Sebastian Bergmann 和贡献者。
我的 PHP 可以工作,因为“php -v”返回版本等。但是当我运行 phpunit.cmd 时,我得到这个:
P:\phpunit>■@
'■@' is not recognized as an internal or external command, operable program or batch file.
我做错了什么?
编辑:
按照@delboy1978uk 的建议运行“php phpunit.phar”,为我提供了phpunit 的命令选项列表。那为什么我会得到那些奇怪的字符呢?
最佳答案
我完全删除了脚本文件,从头开始制作一个新的,添加了行 “php phpunit.phar %*”(不带双引号),现在可以使用了。也许是一个奇怪的文件编码?
关于phpunit 不能在 Windows 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45984403/