I successfully installed PHPUnit on my desktop PC and decided to have it on my laptop PC, but... then I try to create PHPUnit test Netbeans throws an error "Selected PHPUnit (version ?.?.?) is to old, upgrade it if possible (the minimum version is 3.3.0).".
Of course my PHPUnit version is newer - 3.5.5-2. Where is the problem?
I am using
Ubuntu 11.04
Netbeans 6.9
PEAR Version: 1.9.1
PHP Version: 5.3.5-1ubuntu7.2
Zend Engine Version: 2.3.0
As I understand the problem is with PHPUnit. When I try to call "phpunit" command in terminal I receive PHP Fatal error:
root#ubuntu:~# phpunit –version
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
root#ubuntu:~# find / -name CodeCov*
root#ubuntu:~#
As you can see there is no such file or folder in my PC. What to do?
I tried to reinstall it many times (with apt-get, pear, Synaptic PM...), but always get the same result.
Problem solved.
Follow #David Harkness comment I tried to install PHP_CodeCoverage and then I realized that my PEAR Installer is too old. I Upgraded it to 1.9.2 and then reinstalled PHPUnit.
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
$ pear install phpunit/PHPUnit
What's quite strange because all software was freshly installed week ago.
Answer. How I installed PHPUnit finally.
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install phpunit/PHP_CodeCoverage
sudo pear install phpunit/PHPUnit
If You still have problems try to update PEAR:
sudo wget http://pear.php.net/go-pear.phar
sudo php go-pear.phar
configure channel autodiscovery
sudo pear config-set auto_discover 1
simply upgrade / install phpunit with --alldeps flag enabled
sudo pear upgrade --alldeps channel://pear.phpunit.de/PHPUnit
and it automatically does the necessary magics. :)
Update:
http://pear.phpunit.de/ has gone away (Returns 410)
The other solutions here did not work for me. I finally found a solution that worked for me here:
http://markojakic.net/configure-phpunit-and-pear-in-ubuntu-12-04
Essentially pear by default for me was installing binaries to my home directory. To fix it I ran the following commands
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
sudo pear uninstall phpunit/PHPUnit
sudo pear install phpunit/PHPUnit
PHAR FTW!
$ wget http://pear.phpunit.de/get/phpunit.phar
$ chmod +x phpunit.phar
Ref: https://github.com/sebastianbergmann/phpunit/blob/master/README.md
To get the latest version of pear and phpunit.
pear upgrade
pear upgrade pear
pear upgrade phpunit/PHPUnit
Related
I want to install PHP Copy Paste Detector on Ubuntu machine, for this I used that command:-
sudo pear config-set auto_discover 1
that is run scussfully, but when I try that command:-
sudo pear install pear.phpunit.de/phpcpd
this is showing error message
error is :-
No releases available for package "pear.phpunit.de/phpcpd"
install failed
I tried many command for this like:-
pear config-set auto_discover 1
pear install --force --alldeps pear.phpqatools.org/phpqatools
sudo pear channel-discover pear.phpunit.de
pear clear-cache etc. but one help full for me.
Sebastian Bergmann, author of phpunit, switched off phpunit's pear channel some time ago rendering your efforts useless.
You now need to use either the .phar or install phpcpd via composer instead - details are here at https://github.com/sebastianbergmann/phpcpd
In our Development server, we have php 5.2 installed. I was asked to install phpunit on it. I followed the instruction on phpunit site as below:
http://phpunit.de/manual/3.6/en/installation.html
Note
PHPUnit 3.6 requires PHP 5.2.7 (or later) but PHP 5.3.9 (or later) is
highly recommended. PHP_CodeCoverage, the library that is used by
PHPUnit to collect and process code coverage information, depends on
Xdebug 2.0.5 (or later) but Xdebug 2.1.3 (or later) is highly
recommended.
The following two commands (which you may have to run as root) are all
that is required to install PHPUnit using the PEAR Installer:
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
But there is error when i run phpunit command after installation:
[root#dev ~]# phpunit
PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16
I have tested it on fresh Centos 5 installation as well but all is useless. I am fed up of phpunit. Please suggest what to do.
I have manually uninstalled and installed as below:
First you need to uninstall PHPUnit 3.6 and all of it’s dependencies.
sudo pear uninstall phpunit/PHPUnit
sudo pear uninstall phpunit/DbUnit
sudo pear uninstall phpunit/PHP_CodeCoverage
sudo pear uninstall phpunit/File_Iterator
sudo pear uninstall phpunit/Text_Template
sudo pear uninstall phpunit/PHP_Timer
sudo pear uninstall phpunit/PHPUnit_MockObject
sudo pear uninstall phpunit/PHPUnit_Selenium
sudo pear uninstall pear.symfony-project.com/YAML
Next install these specific versions of each dependency, in this order, installing PHPUnit-3.5.15 last.
sudo pear install pear.symfony-project.com/YAML-1.0.2
sudo pear install phpunit/PHPUnit_Selenium-1.0.1
sudo pear install phpunit/PHPUnit_MockObject-1.0.3
sudo pear install phpunit/PHP_Timer-1.0.0
sudo pear install phpunit/File_Iterator-1.2.3
sudo pear install phpunit/PHP_CodeCoverage-1.0.2
sudo pear install phpunit/Text_Template-1.0.0
sudo pear install phpunit/DbUnit-1.0.0
sudo pear install phpunit/PHPUnit-3.5.15
From the site: http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/
The error is same as
PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16
Please suggest any ideas to solve this.
I got it fixed and glad to share the answer back.
ISSUE CAUSE:
The issue was that I was following some procedure which was not supported to php 5.2. The link of that document is as below:
http://phpunit.de/manual/3.7/en/installation.html
I used pear to uninstall PHPUnit which did not uninstall it properly and the binary was left in the system.
SOLUTION:
For php 5.2 we require to install phpunit 3.6 from:
http://phpunit.de/manual/3.6/en/installation.html
Even then When phpunit command was executed, it shown the below mentioned result.
[root#localhost]# phpunit
-bash: /usr/local/bin/phpunit: No such file or directory
We need to Remove the binary left at /usr/local/bin/phpunit because pear installed the binary at:
/usr/bin/phpunit
The solution was to run phpunit through: /usr/bin/phpunit or copy the binary to /usr/local/bin/phpunit
cp /usr/bin/phpunit /usr/local/bin/
Ok, I'm using a MacBook and have MAMP PRO installed for PHP environment.
I'm trying to use Pear to install PHPUnit, but can't get it working. PHPUnit tells me pear: command not found
I came across a tutorial that suggests using sudo php install-pear-nozlib.phar to install pear, but when I run it, I get the following:
[PEAR] Archive_Tar - already installed: 1.3.7
[PEAR] Console_Getopt - already installed: 1.3.0
[PEAR] Structures_Graph- already installed: 1.0.4
[PEAR] XML_Util - already installed: 1.2.1
[PEAR] PEAR - already installed: 1.9.4
Wrote PEAR system config file at: /Applications/MAMP/bin/php/php5.4.10/conf/pear.conf
You may want to add: /Applications/MAMP/bin/php/php5.4.10/lib/php to your php.ini include_path
okay, so it thinks Pear is already installed, but I can't seem to reference it to do anything without the command not found error. I'm thinking that there's some sort of conflict as it's already installed as part of MAMP, but that the MAMP version isn't being referenced through the command line?
I know very little about terminal commands. Is my thinking even on the right track?
The answer is in the error message:
You may want to add: /Applications/MAMP/bin/php/php5.4.10/lib/php
to your php.ini include_path
There is the MAMP install of PHP & the systemwide PHP. You need to use the MAMP specific install of PHP. Try this command.
sudo /Applications/MAMP/bin/php/php5.4.10/lib/php install-pear-nozlib.phar
Also, here are my notes on installing phpunit under Mac OS X 10.6.8. Should work for Mac OS X 10.9. Mind you this is for a system install of phpunit and not MAMP specific.
First get curl to get the go-pear.phar:
http://pear.php.net/go-pear.phar > go-pear.phar
At this point you might need to edit your .bash_profile and add /usr/local/pear/bin to $PATH.
Now run go-pear.phar:
sudo php -q go-pear.phar
Set the pear channels:
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover pear.symfony.com
Might need to explicitly indicate with pear you need when running the commands so this can work as well:
sudo /usr/local/pear/bin/pear channel-discover pear.phpunit.de
sudo /usr/local/pear/bin/pear channel-discover components.ez.no
sudo /usr/local/pear/bin/pear channel-discover pear.symfony-project.com
sudo /usr/local/pear/bin/pear channel-discover pear.symfony.com
Now install phpunit:
sudo pear install --alldeps phpunit/PHPUnit
Now edit php.ini:
sudo nano /etc/php.ini
Find the includes path entry:
;include_path = ".:/php/includes/"
Uncomment—if it is commented—and change it to include the pear path:
include_path = ".:/usr/local/pear/share/pear:/php/includes/"
I am not quite sure if the question belongs to this forum, so if not and you are about to close this question, please make a suggestion where else to ask this question.
Basically, I need to install phpunit on Ubuntu 12.04. By doing so with the packet manager I get an error when running phpunit:
PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38
for which there are solutions, i.e. to install phpunit with pear.
Following the pear install instructions I download and run go-pear.phar, which itself produces an error
PHP Notice: Uninitialized string offset: 0 in phar:///home/alexander/opt/src/go-pear.phar/Console/Getopt.php on line 145
Any suggestions how to proceed from here? I also ONLY need phpunit, so pear will be used just for this case once.
The installation of phpunit really seems to be extremly complicated and circumstantial, but here is the solution:
As for Ubuntu 12.04 pear should be already installed
However, the latest version of pear should be used
And phpunit need to be removed before it is reinstalled
The whole procedure and each step is described on symfony-world, one might need the additional step shown in the given comment. Here is a copy-and-paste of the complete procedure for Ubuntu 12.04:
sudo apt-get remove phpunit
sudo apt-get upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony.com
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit
if you need only phpunit, use composer.. For example composer.json may look like:
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
I've installed PHPUnit on my OS X Snow Leopard box using the following command:
sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
I would expect that the phpunitCLI command would be available after that, but it isn't. I've looked in /usr/local/bin and /usr/lib/php/PHPUnit but can't find anything that looks like a CLI.
Can anyone tell me how to get the CLI up and running?
I had the same problem, I received no errors after the pear installation, but some directories and files where installed (under /usr/lib/php/pear) and others missing (I had no phpunit.sh file among others).
My setup: OSX Lion 10.7.2 + PHP 5.3.6 + PEAR 1.9.2.
I can't really say for sure what the problem was, but I found that the PEAR installer was not up to date, so I upgraded it (to 1.9.4) with:
sudo pear upgrade pear
After that, following the phpunit manual, I typed:
sudo pear config-set auto_discover 1
So yo don't need to add the channels for every package and dependency. And then:
sudo pear install --alldeps pear.phpunit.de/PHPUnit
And voilà, everything is working finally!
I had the same problem, after checking installation page and running below commands, it started working. Just make sure to remove it before running them.
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install phpunit/PHPUnit
Do not forget to clear the cache after discovering the channels:
sudo pear clear-cache
I couldn't install anything with PEAR and clearing the cache worked for me