Install PHPUnit on OSX Mavericks
-
21-12-2019 - |
Question
I'm trying to install PHPUnit on my MBP with OSX Mavericks. The install part is going great, pear throws no errors, exceptions or whatsoever. But when I try to execute the phpunit command in terminal it does throw an error.
I've searched far and wide for an answer, but I can't find anything that solves the problem.
This is what happens:
- Installing PHPUnit (pear install phpunit/PHPUnit) it's saying it's already installed (that's correct).
- When I list all the installed packages in pear (pear list), PHPUnit does not show up in the list.
- When I execute the pear list-all command it shows up twice as PHPUNIT (which is version 1.3.2) and PHPUNIT2 (version 2.3.6).
- And when I try to execute the phpunit command it throws an error (twice):
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:') in /usr/local/pear/share/pear/PHPUnit/Autoload.php on line 64
EDIT: I had it working on Mountain Lion, but since I've upgraded to Mavericks phpunit was broken. Also, I've checked the directory of the autoload.php, and the file is there..
Can somebody please explain what's going on? It's starting to drive me mad..
Solution
The solution was to use the IDE PHPStorm and Composer. Which gives the advantage to install dependencies on a project base.
Thanks to Paves S. for the recommendation.
For more information on how to install:
http://www.jetbrains.com/phpstorm/webhelp/enabling-phpunit-support.html
OTHER TIPS
If you installed php using MacPorts, you need to set your include_path
in php.ini to:
include_path = ".:/opt/local/lib/php/:/opt/local/lib/php/PEAR/"
I also reinstalled PHPUnit, as there were some dependancies issues (Generator.php missing):
You can run this as root (found this script here and added --alldeps option when reinstalling):
pear list -c phpunit | grep stable | awk '{print "phpunit/"$1}' | xargs pear uninstall
pear install --alldeps phpunit/phpunit