Reputation: 142
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]
blablabla
but 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?
Upvotes: 7
Views: 12789
Reputation: 152
as far as I know PEAR installation method comes to his end, this is what's says about it on the github repository.
https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation-Method
Upvotes: 0
Reputation: 51
In Ubuntu, I used
pear config-set auto_discover 1
pear install pear.phpunit.de/PHP_CodeCoverage
Upvotes: 5
Reputation: 4138
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
Upvotes: 7
Reputation: 27856
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
Upvotes: 1
Reputation: 11360
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);
?>
Upvotes: 8