Search code examples
phpphpunitpearphpstorm

How can I get IDE autocomplete for PHPUnit if I installed from source?


I know it seems like a duplicate, but my problem is different:

Since I installed PHP from source, some folders are not there. I installed PHPUnit the usual way using pear.

Normally I would add /usr/share/php to the include path of the IDE or project and be done. But that folder doesn't exist.

$ updatedb
$ locate phpunit
/usr/local/bin/phpunit
/usr/local/lib/php/.channels/pear.phpunit.de.reg
/usr/local/lib/php/.channels/.alias/phpunit.txt
/usr/local/lib/php/.registry/.channel.pear.phpunit.de
/usr/local/lib/php/.registry/.channel.pear.phpunit.de/phpunit.reg

$ locate PHPUnit
/usr/local/lib/php/doc/PHPUnit
/usr/local/lib/php/doc/PHPUnit/LICENSE
/usr/local/lib/php/doc/PHPUnit/README.md

I tried including /usr/local/lib/php, but I still get "undefined class PHPUnit_Framework_TestCase"

Note that php and phpunit work fine, I only need help with IDE autocompletion.

What can I do?


Solution

  • As of PHPUnit v4 PEAR distribution now contains PHAR version instead of lots of individual files. And there is one file (phpunit) instead of launcher + php files (on installation phpunit.phar gets renamed into phpunit).

    Because it now has no .phar extension, IDE will not be able to recognize it accordingly.

    The easiest option is to download actual PHAR version of PHPUnit and place in anywhere in your project (e.g. inside vendors folder).