问题描述
Cannot find PHPUnit in include path
是我尝试在phpstorm中运行代码时收到的错误消息.
Cannot find PHPUnit in include path
is the error message I get when I try to run my code in phpstorm.
在"PHP设置"中,我的PHP级别语言是5.4 (traits, short array syntax, etc.)
,解释器是Name(5.4.7)
,其中Name
是用户定义的.
In the PHP Settings, my PHP level language is 5.4 (traits, short array syntax, etc.)
and interpreter is Name(5.4.7)
where Name
is user defined.
当我尝试运行代码时出现错误,确切的消息是:
The error appears when I try to run the code and the exact message is this:
C:\ xampp2 \ htdocs \ ft网站
C:\xampp2\htdocs\ft-website
测试从下午2:34开始...
Testing started at 2:34 PM ...
以退出代码1完成的过程
Process finished with exit code 1
在包含路径(.; C:\ xampp2 \ php \ PEAR)中找不到PHPUnit`
Cannot find PHPUnit in include path (.;C:\xampp2\php\PEAR)`
推荐答案
我自己也遇到了这个问题.
Just encountered this problem myself.
我不确定为什么无法在包含路径中找到PHPUnit(尽管事实是 在那里,尽管都是小写).
I'm unsure why it is unable to find PHPUnit in the include path (despite the fact that it is there, albeit in all lowercase).
我通过更改PHPUnit的IntelliJ首选项(在PHP --> PHPUnit
下)解决了这个问题.我将PHPUnit library
设置更改为Use custom loader
,然后指定了phpunit
可执行文件的路径.在我的Mac上是/usr/local/Cellar/php54/5.4.26/bin/phpunit
.
I got around this by changing my IntelliJ Preferences for PHPUnit (under PHP --> PHPUnit
). I changed the PHPUnit library
settings to Use custom loader
and then specified the path to the phpunit
executable. On my mac, that was /usr/local/Cellar/php54/5.4.26/bin/phpunit
.
更新:
我刚刚发现pear
现在将PHPUnit安装为名为phpunit
的phar
.它先前安装了PHPUnit源,对于PHPStorm中的参考和代码完成而言,它确实很棒.我认为这是PHPStorm不再起作用的原因,因为它期望使用php可执行文件而不是php归档文件.
I just discovered that pear
now installs PHPUnit as a phar
named phpunit
. It previously installed the PHPUnit source, which was really nice for reference and code completion in PHPStorm. I think that this is the reason things aren't working any longer with PHPStorm, because it's expecting a php executable and not a php archive.
因此,我不再使用pear
安装PHPUnit,而是使用 composer 代替.这将PHPUnit直接捆绑为我的项目的依赖项,这使其比系统依赖项更具移植性.您需要在PHPStorm首选项中将vendor/phpunit/phpunit
作为PHP包含路径添加.这将有两个目的:
So, I'm moving away from using pear
to install PHPUnit, and I'm using composer instead. This bundles PHPUnit directly as a dependency of my project, which makes it more portable than a system dependency. You'll need to add vendor/phpunit/phpunit
as a PHP include path in your PHPStorm preferences. This will serve two purposes:
- PHPStorm现在可以找到
phpunit
可执行文件 - PHPStorm现在将为所有
PHPUnit
类建立索引,因此您将自动完成.是的!
- PHPStorm can find the
phpunit
executable now - PHPStorm will index all the
PHPUnit
classes now, so you'll get auto-complete. Yay!
为此,请转到PhpStorm设置中的语言和框架".如果单击PHP,则在右侧会有您的包含路径
To do this, go to Languages and Frameworks in the PhpStorm settings.If you click on PHP, on the right you have your include paths
这篇关于在包含路径phpstorm中找不到PHPUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!