Installation and configuration of PHPUnit in Windows

Installation and configuration of PHPUnit in Windows

Version control

Language:PHP 5.3.0(>5.2.7)
Web Server:WampServer Version 2.0
System:Windows 7
Folder path:c:\wamp\bin\php
PHP version should greater than 5.2.7. To install a new version of PHP, click the icon of Wamp, and then php->Version -> Get more.

Attention: if you install a new version PHP, after the installation, it is better to check the environment variable PHP_PEAR_PHP_BIN is point to the new folder of PHP. And the php.ini which will used by command line is the one you could find in the new folder of PHP.

Installation PEAR

Attention: All the installation will be in command line. To launch a Terminal in windows, go to Start -> Run -> type CMD.

Go to the folder of PHP :


> cd c:\wamp\bin\php\php5.3.0

By default, there is file which is called go-pear.bat, execute it :


> go-pear.bat

2

For someone who has problem in the following steps, it maybe solved by this:Download the newest phar for pear from: http://pear.php.net/manual/en/installation.getting.php

And put it in c:\wamp\bin\php\php5.3.0\PEAR, then launch the command line:


> php go-pear.phar

Remarkable for php 5.3.5In case of error “phar does not have a signaturePHP”, edit the file php.ini(c:\wamp\bin\php\php5.3.5), find the line “phar.require_hash”, normally it is in comment, just uncomment it and change its value to Off.

During the installation, you will find the following screen-shots. What you have to attention and modify will be the 11 and 12.

4

Normally, we will do this to find the configuration files easily in the future.

11. Name of configuration file : C:\wamp\bin\php\php5.3.5\pear.ini

12. Path to CLI php.exe : C:\wamp\bin\php\php5.3.5\.

5

Then tape Enter to continue…

Execute the file PEAR_ENV.reg to generate the environment variable automatically.

> PEAR_ENV.reg

PHPUnit needs curl, so it should uncomment or add this line in php.ini :

Extension=php_curl.dll

Installation PHPUnit with Pear

First, add the channels of PHPUnit for Pear

>pear channel-discover pear.phpunit.de
>pear channel-discover pear.phpunit.de
>pear channel-discover pear.phpunit.de

Second, upgrade pear:

> pear upgrade-all

Third, install phpunit:

> pear install –a phpunit/PHPUnit

or

> pear install –alldeps phpunit/PHPUnit

If you have finished all the steps and let pear write in your php configuration file, you will find these lines in your php.ini

;***** Added by go-pear
include_path=".;C:\wamp\bin\php\php5.3.0\pear"
;*****

And you should add these lines into the bottom of the configuration file of Apache, in

C:\wamp\bin\apache\Apache2.2.1\bin\php.ini

Now if you launch the command line to list the package of Pear, you should see this:

> pear list -a

PHPUnit 3.5.13 stable (ou 3.6.3 pour php 5.3.5)

And now, if you launch the command line:

> phpunit –version

If it display the version, it means your PHPUnit has been installed.

Note: If you have a problem of “No realeases abailable for package pear.phpunit.de/PHPUnit”, you could do this in Terminal:

> pear update-channels
> pear clear-cache
If you have a problem of "PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream, No such file or directory in C:\wamp\bin\php\php5.3.0\PEAR\PHPUnit\Autoload.php"

7
It is caused by the dependence of pear, so what you should do is add these lines in the php.ini of php and apache, it shall work.

;***** Added by go-pear
include_path=".;C:\wamp\bin\php\php5.3.0\PEAR;C:\wamp\bin\php\php5.3.0\PEAR\PEAR"
;*****
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s