How do I correctly install PHPUnit with PEAR?

I have had to de- and reinstall a newer version of PHPUnit following these directions. Now when I'm launching this line

sudo pear install --alldeps phpunit/PHPUnit

I see an error message, that looks like this.

Unknown remote channel:
phpunit/PHPUnit requires package "channel://" (version >= 2.1.0)
No valid packages found

If I install just Yaml by launching

sudo pear install symfony/YAML

an older version (1.0.6) will be installed that doesn't meet the dependency of PHPUnit. How can I possibly solve this?


I had the same problem while upgrading my phpunit.

This solved the problem:

pear channel-discover
pear install

Then run:

pear install --alldeps

OBS: I think the pear install is not necessary. I'm just posting it because it is exactly the way I solved my problem.

Use this, as described in the PHPUnit docs: (i don't what sudo means, this is how I do it on a windows PC):

pear config-set auto_discover 1
pear install

I also had this error message:

Unknown remote channel:

Solved creating an alias:

pear channel-alias

and then


sudo pear channel-discover

sudo pear update-channels

sudo pear upgrade-all

sudo pear install --force --alldeps phpunit/PHPUnit

First: locate pear you may have multiple versions installed and this could be a pain.

At work we have something like this in our intranet:

sudo [your pear install] channel-update  
sudo [your pear install] upgrade pear  
sudo [your pear install] channel-discover  
sudo [your pear install] install --alldeps phpunit/PHPUnit

I know theres a more automated way to install it using: go-pear ( )

However, if you already have some other install of pear it will totally wreck everything and you'll spend quite some time trying to fix it. I think the biggest hurdle is being able to tell all the libraries where each other is.

sudo pear install -a phpunit
sudo pear channel-discover

I had similar problem complaining about "Unknown remote channel:". had to do (without sudo, I got weird error about cannot open some file)

sudo pear channel-discover


sudo pear install phpunit/PHPUnit

Now I can see phpunit in my /usr/bin

Process mentioned by PutzKipa works however you might need super user privileges. For ubuntu add sudo before each command.

Following Plínio César, I solved it finally, but with slight variation:

First I did a "sudo apt-get remove phpunit" to remove the faulty installation. Then using pear to do the phpunit installation:

sudo pear install

sudo pear channel-discover

sudo pear config-set auto_discover 1

sudo pear install --alldeps

Thanks Plinio Cesar!!!

The easiest way to obtain PHPUnit in Ubuntu, Debian, Fedora or OpenSUSE is to download a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file.

Open the terminal and type:

wget  # download the PHP Archive (PHAR) file  
chmod +x phpunit.phar   
sudo mv phpunit.phar /usr/local/bin/phpunit   

There are many different versions of phpunit.phar at If you use the first command, it will select and download the latest version.

Note: The /usr/local/bin/ path in the last command is correct for Ubuntu, Debian, Fedora and OpenSUSE distributions and also for other Linux distributions that have a /usr/local/bin/ directory.

Reference: What is /usr/local/bin? Came across it in an script installation for Applescript but would like to know more

Need Your Help

Match IPv4 address given IP range/mask?

php regex ip-address

Either with PHP or a RegExp (or both), how do I match a range of IP addresses?

Execute batch in case windows port is not used

windows if-statement batch-file

In a windows batch file, regularly executed by a chronjob, I would like to execute the following command:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.