-
Configure PHPUnit and PEAR in Ubuntu 12.04
Posted by markzero on Wednesday, July 4th, 2012
My problem was that I have wrong installation of PEAR (don’t know how and have no intention on finding it out). When I ran > phpunit, got following error:
PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39This is because you have wrong PEAR installation. My friend on the other hand, also has Ubuntu 12.04 and installed PHPUnit almost as easy as with click of a button (unlike me, of course).
So, I asked him to do in terminal:
$ pear config-showWhich showed this (unlike my config-show):
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels auto_discover
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config
PEAR executables directory bin_dir /usr/bin
PEAR documentation directory doc_dir /usr/share/php/doc
PHP extension directory ext_dir /usr/lib/php5/20090626+lfs
PEAR directory php_dir /usr/share/php
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR configuration file cfg_dir /usr/share/php/cfg
directory
PEAR data directory data_dir /usr/share/php/data
PEAR Installer download download_dir /build/buildd/php5-5.3.10/pear-build-download
directory
PHP CLI/CGI binary php_bin /usr/bin/php
php.ini location php_ini
--program-prefix passed to php_prefix
PHP’s ./configure
--program-suffix passed to php_suffix
PHP’s ./configure
PEAR Installer temp directory temp_dir /tmp/pear/temp
PEAR test directory test_dir /usr/share/php/test
PEAR www files directory www_dir /usr/share/php/htdocs
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 2
Debug Log Level verbose 1
PEAR password (for password maintainers)
Signature Handling Program sig_bin /usr/bin/gpg
Signature Key Directory sig_keydir /etc/pear/pearkeys
Signature Key Id sig_keyid
Package Signature Type sig_type gpg
PEAR username (for username
maintainers)
User Configuration File Filename /home/username/.pearrc
System Configuration File Filename /etc/pear/pear.conf
You need to set following configurations:
sudo pear config-set bin_dir /usr/bin
sudo pear config-set doc_dir /usr/share/php/doc
sudo pear config-set php_dir /usr/share/php
sudo pear config-set cfg_dir /usr/share/php/cfg(make (sudo mkdir cfg) directory here)
sudo pear config-set data_dir /usr/share/php/data
sudo pear config-set test_dir /usr/share/php/test
Then run:
$ sudo pear uninstall phpunit/PHPUnit
$ sudo pear install phpunit/PHPUnit
And this worked for me! If you have any issues, feel free to ask below!
Posted in: PEAR, PHP, PHPUnit, Ubuntu.
Share this story:
7 Responses to “Configure PHPUnit and PEAR in Ubuntu 12.04”
Leave a Reply
Useful Links
Categories
Archives















Awesome! Thank you so much for this!
Report this comment
Ah that worked and solved the issue thanks for this.
Just to note this was needed to run after the config was set and before the re-install
pear channel-discover pear.phpunit.de
Thanks
Report this comment
Nice! Worked!
I re-install pear channel-discover pear.phpunit.de too
Report this comment
thanks! it works …
Report this comment
It says:
Unknown remote channel: pear.symfony.com
phpunit/PHPUnit requires package “channel://pear.symfony.com/Yaml” (version >= 2.0.0, version <= 2.2.99)
No valid packages found
install failed
Please help..
Report this comment
Hi Suraj, I think it is related to Symfony framework, not sure if I can help there. Do you have Yaml extension installed? With proper version also!
Report this comment
PHP Fatal error: require_once(): Failed opening required ‘/usr/bin/phpunit.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /home/haritha/x.php on line 4
I am getting the above error when I am running phpunit x.php in the terminal.
Line 4 in my code is :-
require_once ‘/usr/bin/phpunit.php’;
Report this comment