作者:aguiladesilvo_502 | 来源:互联网 | 2023-05-19 05:06
CannotfindPHPUnitinincludepathistheerrormessageIgetwhenItrytorunmycodeinphpstorm
Cannot find PHPUnit in include path
is the error message I get when I try to run my code in phpstorm.
在include路径中找不到PHPUnit是我在phpstorm中运行代码时得到的错误消息。
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.
在PHP设置中,我的PHP级别语言是5.4(特征、短数组语法等),解释器是Name(5.4.7),其中Name是用户定义的。
The error appears when I try to run the code and the exact message is this:
当我试图运行代码时出现错误,确切的消息是:
C:\xampp2\php\php.exe C:\Users\DELL\AppData\Local\Temp\ide-phpunit.php --no-configuration
C:\ php xampp2 \ php \。exe C:\Users\DELL\AppData\Local\Temp\ ide-phpunit。php——了无配置
C:\xampp2\htdocs\ft-website
C:\ xampp2 \根\ ft-website
Testing started at 2:34 PM ...
测试从下午2:34开始……
Process finished with exit code 1
使用退出代码1完成进程
Cannot find PHPUnit in include path (.;C:\xampp2\php\PEAR)`
无法在包含路径(.;C:\xampp2\php\PEAR)中找到PHPUnit。
5 个解决方案
48
Just encountered this problem myself.
我自己也遇到过这个问题。
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).
我不确定为什么它不能在include路径中找到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
.
我通过更改PHPUnit的IntelliJ首选项(在PHP下——> PHPUnit)来解决这个问题。我将PHPUnit库设置更改为使用自定义加载程序,然后指定到PHPUnit可执行文件的路径。在我的mac上,那是/usr/ local/cellar/php54 /5.4.26/ bin/phpunitit。
UPDATE:
更新:
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安装为PHPUnit。它之前安装了PHPUnit源代码,这对于PHPStorm中的引用和代码完成是非常好的。我认为这就是PHPStorm不能工作的原因,因为它需要的是php可执行文件而不是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:
因此,我不再使用pear来安装PHPUnit,而是使用composer。这将PHPUnit直接打包为我的项目的依赖项,这使得它比系统依赖项更具可移植性。您将需要添加供应商/phpunit/phpunit作为PHP包含路径的PHPStorm首选项。这将达到两个目的:
- PHPStorm can find the
phpunit
executable now
- PHPStorm现在可以找到phpunit可执行文件
- PHPStorm will index all the
PHPUnit
classes now, so you'll get auto-complete. Yay!
- PHPStorm将会索引所有的PHPUnit类,所以你会自动完成。耶!
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设置中的语言和框架。如果你点击PHP,在右边你有你的包含路径