laravel 供应商/bin/phpunit 不适用于 Lumen
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38422499/
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
vendor/bin/phpunit not working for Lumen
提问by KMK
I'm new to Lumen (and Laravel). I've created a project with Composer and now I'm trying to get PHPUnit to work.
我是 Lumen(和 Laravel)的新手。我已经用 Composer 创建了一个项目,现在我正在尝试让 PHPUnit 工作。
I'm following a book, where it should be possible to run a default passing test by typing vendor/bin/phpunit
in the terminal, but it gives the error:
我正在关注一本书,应该可以通过vendor/bin/phpunit
在终端中键入来运行默认的通过测试,但它给出了错误:
'vendor' is not recognized as an internal or external command, operable program or batch file
'vendor' 不是内部或外部命令,也不是可运行的程序或批处理文件
I've checked that the phpunit file is actually there and that phpunit is added as dependency in my composer.json file. I've also tried ./vendor/bin/phpunit
and vendor/bin/phpunit/phpunit
, but with the same result.
我已经检查过 phpunit 文件是否确实存在,并且 phpunit 已作为依赖项添加到我的 composer.json 文件中。我也试过./vendor/bin/phpunit
and vendor/bin/phpunit/phpunit
,但结果相同。
I've searched Google to find a solution, but everyone else seem to have issues when running phpunit
(wihout vendor/bin) and the solution is to use the full path vendor/bin/phpunit, but since I'm already doing that, it does not fix my problem.
我已经在谷歌上搜索了一个解决方案,但其他人在运行时似乎都有问题phpunit
(没有 vendor/bin),解决方案是使用完整路径 vendor/bin/phpunit,但由于我已经这样做了,它不能解决我的问题。
I'm using PHPStorm on a Windows machine and running the PHP server via PHPStorm. I've not modified the default Lumen project.
我在 Windows 机器上使用 PHPStorm 并通过 PHPStorm 运行 PHP 服务器。我没有修改默认的 Lumen 项目。
Any help is greatly appreciated!
任何帮助是极大的赞赏!
UPDATE:
更新:
Trying php vendor/bin/phpunit
gives the following error:
尝试php vendor/bin/phpunit
给出以下错误:
You need to set up the project dependencies using the following commands:
wget http://getcomposer.org/composer.phar
php composer.phar install
您需要使用以下命令设置项目依赖项:
wget http://getcomposer.org/composer.phar
php composer.phar install
I'm not sure what that means, since I've already installed Composer. I used Composer to create the project and I haven't changed the dependencies from the default.
我不确定这意味着什么,因为我已经安装了 Composer。我使用 Composer 创建项目,并且我没有更改默认的依赖项。
回答by KMK
It turned out that some symlinks and permissions were not installed properly in the default project. I tried deleting the entire vendor/ directory and run composer install
.
事实证明,默认项目中未正确安装某些符号链接和权限。我尝试删除整个 vendor/ 目录并运行composer install
.
Now I can run phpunit with the command vendor\bin\phpunit
(because I'm running on Windows - thanks Nizarii)
现在我可以使用命令运行 phpunit vendor\bin\phpunit
(因为我在 Windows 上运行 - 感谢 Nizarii)
回答by Nizarii
I had the same problem, for Windows it's vendor\bin\phpunit
;)
我遇到了同样的问题,对于 Windows,它是vendor\bin\phpunit
;)
回答by Raymond Cheng
try this:
尝试这个:
php vendor/bin/phpunit