phpunit - wrong path
Solution 1
Try adding /opt/local/PEAR
to your php.ini
file include_path.
//Before:
include_path='.:/usr/lib/php'
//After:
include_path='.:/usr/lib/php:/opt/local/PEAR'
You may also need to restart your web server afterwards for the changes to take effect.
And as RobertPitt comments, this can also be done at runtime without access to the php.ini file.
<?php
$path = '/opt/local/PEAR';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
?>
Solution 2
The PEAR channel (pear.phpunit.de) that is used to distribute PHPUnit needs to be registered with the local PEAR environment. Furthermore, component that PHPUnit depends upon are hosted on additional PEAR channels.
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel:
pear install phpunit/PHPUnit
Solution 3
In Ubuntu, I used
pear config-set auto_discover 1
pear install pear.phpunit.de/PHP_CodeCoverage
Solution 4
For Ubuntu edit this php.ini for CLI:
/usr/local/lib/php.ini
add /usr/local/lib/php/ to your include line
include_path= "/opt/zend/library/:/var/www/library/:/usr/local/bin/pear/:/usr/local/lib/php/"
Took me a day to figure it out. Bingo.
If this does not work, try this, it will give you a hint where your PHP libs are located.
$ locate PHP_CodeCoverage
Related videos on Youtube
davs
"Give me a stick long enough and a pivot and I shall move the world."
Updated on June 04, 2022Comments
-
davs almost 2 years
Does anybody know what I'm doing wrong? I've installed phpunit, and everything is fine when I'm in the /opt/local/PEAR directory, so if I go to /opt/local/PEAR directory and run phpunit I get:
PHPUnit 3.5.11 by Sebastian Bergmann.
Usage: phpunit [switches] UnitTest [UnitTest.php]
phpunit [switches]
blablablabut if I am on some other path I get:
Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/local/bin/phpunit on line 38
Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/lib/php') in /usr/local/bin/phpunit on line 38
I know that is something wrong with my PATH. How can I fix it?
-
akohout over 10 yearsThis worked for me. I had to uninstall it first, added the discover channels and then installed it again.