40

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: pear.symfony.com
phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (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?

Community
  • 1
  • 1
twigmac
  • 1,772
  • 3
  • 21
  • 38
  • Pear is giving me troubles. This solved it for me: https://askubuntu.com/questions/451953/php-pear-is-not-working-after-upgrading-to-ubuntu-14-04/451975#451975 – eddy147 Sep 30 '14 at 17:54

8 Answers8

85

I had the same problem while upgrading my phpunit.

This solved the problem:

pear channel-discover pear.symfony.com
pear install pear.symfony.com/Yaml

Then run:

pear install --alldeps pear.phpunit.de/PHPUnit

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

Plínio César
  • 5,965
  • 3
  • 23
  • 30
  • 1
    This actually worked and now I understand why it didn't beforehand. The symfony project operates two different pear channels. [http://pear.symfony-project.com/](http://pear.symfony-project.com/) is for version 1 and [http://pear.symfony.com/](http://pear.symfony.com/) for version 2. Only the latter contains YAML2, which is needed by PHPUnit. Thanks, PutzKipa! – twigmac Sep 22 '12 at 23:33
  • 1
    And yes the command `pear install pear.symfony.com/Yaml` hasn't been necessary to install PHPUnit. – twigmac Sep 22 '12 at 23:37
  • I also had to download the CodeCoverage from Github repo https://github.com/sebastianbergmann/php-code-coverage and link to it in the PHPUnit directory: sudo mv ./PHP/CodeCoverage.php ./PHP/CodeCoverage.php.bak; sudo ln -s /home/my-cloned-github-repo-dir/php-code-coverage/PHP/CodeCoverage.php ./PHP/CodeCoverage.php; sudo ln -s /home/my-cloned-github-repo-dir/PHP/CodeCoverage ./PHP/CodeCoverage; # "I'm on ubuntu 12.04" – knb Sep 25 '12 at 16:48
  • This process also didn't solve the problem I stated [here](http://stackoverflow.com/questions/13797778/installing-doctrine2-with-pear?lq=1). YAML was being installed with backdated versions. And the other components of Doctrine too. – Lenin Dec 10 '12 at 09:08
10

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 pear.phpunit.de/PHPUnit
Wouter J
  • 41,455
  • 15
  • 107
  • 112
5

I also had this error message:

Unknown remote channel: pear.symfony.com

Solved creating an alias:

pear channel-alias pear.symfony-project.com pear.symfony.com

and then

channel-discover pear.symfony-project.com

sudo pear channel-discover components.ez.no

sudo pear update-channels

sudo pear upgrade-all

sudo pear install --force --alldeps phpunit/PHPUnit
Paulo
  • 13,937
  • 1
  • 20
  • 10
  • This process also didn't help solve mine. But I solved in a different way [here](http://stackoverflow.com/questions/13797778/installing-doctrine2-with-pear?lq=1). – Lenin Dec 10 '12 at 09:12
2

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 pear.php.net  
sudo [your pear install] upgrade pear  
sudo [your pear install] channel-discover pear.phpunit.de  
sudo [your pear install] install --alldeps phpunit/PHPUnit

I know theres a more automated way to install it using: go-pear ( http://pear.php.net/manual/en/installation.getting.php )

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.

Parris
  • 17,833
  • 17
  • 90
  • 133
  • Didn't help in resetting PEAR for this [problem](http://stackoverflow.com/questions/13797778/installing-doctrine2-with-pear?lq=1). Expecting your answer there. :) – Lenin Dec 10 '12 at 09:11
0
sudo pear install -a phpunit
sudo pear channel-discover pear.phpunit.de

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

sudo pear channel-discover pear.symfony.com

then

sudo pear install phpunit/PHPUnit

Now I can see phpunit in my /usr/bin

Jie Qin
  • 23
  • 1
  • 3
0

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

Bimal
  • 865
  • 10
  • 18
0

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 pear.symfony.com/Yaml

sudo pear channel-discover pear.phpunit.de

sudo pear config-set auto_discover 1

sudo pear install --alldeps pear.phpunit.de/PHPUnit

Thanks Plinio Cesar!!!

Peter Teoh
  • 6,337
  • 4
  • 42
  • 58
0

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 https://phar.phpunit.de/phpunit.phar  # 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 https://phar.phpunit.de/. 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

karel
  • 5,489
  • 46
  • 45
  • 50