在PhpStorm 2016.1上使用Laravel / Homestead启用PHPUnit

时间:2016-05-13 16:20:18

标签: laravel phpunit vagrant phpstorm homestead

我正在研究vagrant / homestead,并配置了一个盒子。

我可以在PhpStorm中启用Xdebug!

现在,我想启用PHPUnit,但我不能这样做......

我遵循了几个教程: https://blog.mayflower.de/5274-Run-your-tests-with-PHPStorm-on-your-vagrant-box.html https://confluence.jetbrains.com/display/PhpStorm/Running+PHPUnit+tests+over+SSH+on+a+remote+server+with+PhpStorm 以下是我的设置:

Php 7 Interpreter Via Vagrant

Php 7 Interpreter

Server

Phpunit

Configuration

以下是运行带代码覆盖率的PhpUnit时收到的消息

vagrant:///Users/julien/Homestead/usr/bin/php -dxdebug.coverage_enable=1 /home/vagrant/.phpstorm_helpers/phpunit.php --coverage-clover   /home/vagrant/.phpstorm_helpers/coverage/Laravel_PhpUnit.coverage -- configuration /home/vagrant/Code/vendor/autoload.php  /Users/julien/Documents/Proyectos/laravel/tests/functional
Testing started at 11:12 AM ...


bash: line 0: cd:  /Users/julien/Documents/Proyectos/laravel/tests/functional: No such file or  directory
PHP Fatal error:  Uncaught UnexpectedValueException: Cannot create phar  '/home/vagrant/Code/vendor/bin', file extension (or combination) not  recognised or the directory does not exist in  /home/vagrant/.phpstorm_helpers/phpunit.php:181
Stack trace:
Fatal error: Uncaught UnexpectedValueException: Cannot create phar   '/home/vagrant/Code/vendor/bin', file extension (or combination) not  recognised or the directory does not exist in  /home/vagrant/.phpstorm_helpers/phpunit.php on line 181#0  /home/vagrant/.phpstorm_helpers/phpunit.php(181): Phar- >__construct('/home/vagrant/C...')

#1 /home/vagrant/.phpstorm_helpers/phpunit.php(250):    IDE_PHPUnit_Loader::init()

#2 {main}
UnexpectedValueException: Cannot create phar '/home/vagrant/Code/vendor/bin', file extension (or combination) not recognised or the directory does not exist in /home/vagrant/.phpstorm_helpers/phpunit.php on line 181
thrown in /home/vagrant/.phpstorm_helpers/phpunit.php on line 181

Call Stack:
0.0006     442920   1. {main}() /home/vagrant/.phpstorm_helpers/phpunit.php:0
0.0006     442920   2. IDE_PHPUnit_Loader::init() /home/vagrant/.phpstorm_helpers/phpunit.php:250
0.0006     451168   3. Phar->__construct() /home/vagrant/.phpstorm_helpers/phpunit.php:181


Process finished with exit code 255

1 个答案:

答案 0 :(得分:1)

使用PhpStorm和PHPUnit设置vagrant可能有点令人生畏,因为它真的不是那么直接...从你的控制台输出我会说你的解释器设置不正确,因为它在你的本地机器上执行PHP 。

总是对我有用的方法是将vagrant设置为SFTP部署配置,并将该配置用作PHP解释器。由于您已经在使用Homesteasd,因此这些教程可能会为设置提供更多信息:

以下是必要部分:

Set interpreter Configure STFP Deployment Configure path mappings Configure PHPUnit