Cannot find PHPUnit in include path phpstorm

前端 未结 7 1457
-上瘾入骨i
-上瘾入骨i 2021-01-31 16:19

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

相关标签:
7条回答
  • 2021-01-31 16:27

    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.

    0 讨论(0)
  • 2021-01-31 16:29

    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"

    0 讨论(0)
  • 2021-01-31 16:31

    This is the way to do it without using composer, and using your global phpunit.

    1. Phpunit now comes with a phar file. My path was /usr/local/Cellar/phpunit/5.0.0/libexec/phpunit-5.0.0.phar

    1. PhpStorm Preferences -> Path to phpunit.phar -> select the phpunit phar

    1. That's all, good stuff.
    0 讨论(0)
  • 2021-01-31 16:32

    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.

    0 讨论(0)
  • 2021-01-31 16:33

    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.

    0 讨论(0)
  • 2021-01-31 16:39

    For those that are looking at it in 2020, starting from PHPStorm 2019 this is under:

    Languages and Frameworks->PHP->Test Frameworks
    
    1. Choose to add a new library
    2. Select "PHPUnit"
    3. Select "Path to phpunit.phar" radio
    4. You'll have an automatic option to download PHPUnit
    0 讨论(0)
提交回复
热议问题