Cannot find PHPUnit in include path
is the error message I get when I try to run my code in phpstorm.
In the PHP Settings, my PHP level language is 5
For future readers, to fix the same issue when using PHPStorm + Vagrant + PHPUnit by defining path to the global phpunit.phar (not composer)
While the tests runned successfully, I was missing the code completion. I had confirmed that phpunit
was in the PATH on my local machine, and to make sure, I had added /usr/local/bin
to the PHP Include paths in PHP Settings
. Still no code completion.
The reason: PHPstorm was looking for phpunit.phar
, not just phpunit
. To fix, on my local machine I established a symlink phpunit.phar
pointing to phpunit
:
$ cd /usr/local/bin/
$ sudo ln -s phpunit phpunit.phar
Then I reindexed the project, and code completion started working.
In addition to Ben's answer, in phpStorm 7.1.3 it works by specifying the phpunit.phar location under the "use custom loader" option, for example:
"Path to script: /usr/share/php/phpunit.phar"
This is the way to do it without using composer, and using your global phpunit.
I had this same problem for PHPStorm 2017 using Vagrant. First go to Settings -> Languages and Frameworks -> PHP
and Add a remote interpreter, then go to Settings -> Languages and Frameworks -> PHP -> PHPUnit
click the + on top and click by Remote Interpreter
. If you're using Composer autoloader, then enter your full Vagrant path to your autoloader file.
I had this problem after adding PHPUnit via composer.
I fixed this by choosing use custom autoloader
in Settings -> Languages and Frameworks -> PHP -> PHPUnit
, then adding /vendor/autoload.php as the location of the custom autoloader.
For those that are looking at it in 2020, starting from PHPStorm 2019 this is under:
Languages and Frameworks->PHP->Test Frameworks