Installing PHPUnit without connecting to PEAR online package
This installation procedure is required when we are getting proxy or any connection errors while we are trying to install PHPUnit package using standard PEAR commands.
Please run the following command in shell:
If the results returns a version which is “1.9.4”, then no need to follow a, b and c
a. Download –
b. Run the following command from the same downloaded directory:
sudo pear upgrade --offline --force PEAR-1.9.4.tgz
c. Please run the following command in shell:
This should return PEAR Version: 1.9.4
Downloading PHPUnit and its dependency packages:
We need to download all the packages related to PHPUnit and all it dependencies manually (using any browser).
Downloading channel files:
For installing any of the above packages, we first need to update all the dependency channel files in pear manually. This can be achieved by downloading all the related channel files for PHPUnit manually and save it as .xml file.
Base Channel file download for PHPUnit:
Symfony project channel file download- download in new folder “symfony”:
Components channel file download- download in new folder “components”:
Adding Channel files:
Make your present working directory (pwd), as the same where channel.xml for pear.phpunit.de is present and run the following command in shell:
sudo pear channel-add channel.xml
sudo pear channel-add symfony/channel.xml
sudo pear channel-add components/channel.xml
Installation of PHPUnit and its dependencies:
Install base PHPUnit package – (You need to install all optional package as mentioned below to make phpunit run properly):
Make your present working directory (pwd), as the same PHPUnit-3.6.11.tgz is present and run the following command in shell:
sudo pear install -f PHPUnit-3.6.11.tgz
Check or update php.ini file:
Once PHPUnit-3.6.11 is installed, check php.ini in shell:
sudo vi /etc/php.ini
search for include_path. It should be enabled as
include_path = ".:/php/includes:/usr/share/pear"
If it is not enabled, please enable it and run the following command in shell:
sudo service httpd restart
Install dependency packages for PHPUnit- In the same order as given below:
sudo pear install -f File_Iterator-1.3.1.tgz
sudo pear install -f PHP_CodeCoverage-1.1.3.tgz
sudo pear install -f PHP_TokenStream-1.1.3.tgz
sudo pear install -f Text_Template-1.1.1.tgz
sudo pear install -f PHP_Timer-1.0.2.tgz
sudo pear install -f PHPUnit_MockObject-1.1.1.tgz
Check for PHPUnit:
Run phpunit on shell, you should get output similar too:
PHPUnit 3.6.11 by Sebastian Bergmann.
Usage: phpunit [switches] UnitTest [UnitTest.php]
phpunit [switches] <directory>
--log-junit <file> Log test execution in JUnit XML format to file.
--log-tap <file> Log test execution in TAP format to file.
--log-json <file> Log test execution in JSON format.