How do I correctly install PHPUnit with PEAR?

对着背影说爱祢 提交于 2019-12-18 10:33:16

问题


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?


回答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.




回答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



回答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



回答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.




回答5:


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




回答6:


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




回答7:


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!!!




回答8:


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



来源:https://stackoverflow.com/questions/12536668/how-do-i-correctly-install-phpunit-with-pear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!