简体   繁体   English

供应商/bin/phpunit 不适用于 Lumen

[英]vendor/bin/phpunit not working for Lumen

I'm new to Lumen (and Laravel).我是 Lumen(和 Laravel)的新手。 I've created a project with Composer and now I'm trying to get PHPUnit to work.我已经用 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.我已经检查过 phpunit 文件是否确实存在,并且 phpunit 已作为依赖项添加到我的 composer.json 文件中。 I've also tried ./vendor/bin/phpunit and vendor/bin/phpunit/phpunit , but with the same result.我也试过./vendor/bin/phpunitvendor/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.我在 Windows 机器上使用 PHPStorm 并通过 PHPStorm 运行 PHP 服务器。 I've not modified the default Lumen project.我没有修改默认的 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 wget http://getcomposer.org/composer.phar
php composer.phar install php composer.phar 安装

I'm not sure what that means, since I've already installed Composer.我不确定这意味着什么,因为我已经安装了 Composer。 I used Composer to create the project and I haven't changed the dependencies from the default.我使用 Composer 创建项目,并且我没有更改默认的依赖项。

我遇到了同样的问题,对于 Windows,它是vendor\\bin\\phpunit ;)

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)现在我可以使用命令vendor\\bin\\phpunit运行vendor\\bin\\phpunit (因为我在 Windows 上运行 - 感谢 Nizarii)

试试这个:

php vendor/bin/phpunit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM