How do I correctly install PHPUnit with PEAR?

24,487

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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.

Share:
24,487
twigmac
Author by

twigmac

Updated on March 05, 2020

Comments

  • twigmac
    twigmac over 4 years

    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?

  • twigmac
    twigmac almost 12 years
    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/ is for version 1 and http://pear.symfony.com/ for version 2. Only the latter contains YAML2, which is needed by PHPUnit. Thanks, PutzKipa!
  • twigmac
    twigmac almost 12 years
    And yes the command pear install pear.symfony.com/Yaml hasn't been necessary to install PHPUnit.
  • knb
    knb over 11 years
    I also had to download the CodeCoverage from Github repo 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/CodeCo‌​verage.php ./PHP/CodeCoverage.php; sudo ln -s /home/my-cloned-github-repo-dir/PHP/CodeCoverage ./PHP/CodeCoverage; # "I'm on ubuntu 12.04"
  • Lenin
    Lenin over 11 years
    This process also didn't solve the problem I stated here. YAML was being installed with backdated versions. And the other components of Doctrine too.
  • Lenin
    Lenin over 11 years
    Didn't help in resetting PEAR for this problem. Expecting your answer there. :)
  • Lenin
    Lenin over 11 years
    This process also didn't help solve mine. But I solved in a different way here.
  • ksiimson
    ksiimson over 11 years
    Brilliant! I always had trouble finding the channels PHPUnit required and I install it frequently
  • samayo
    samayo almost 11 years
    Awesome. You saved me of three days headache. I had to go and upvote all your answers :)