Installing PEAR and PHPUnit

by Klaus Graefensteiner 2. March 2010 10:29

Introduction

This is the third article of a series of blog post called the WIMPinator Chronicles that describe how to setup a PHP development environment for Windows 7 and IIS 7.5.

So far we covered how to install a Wordpress blog and all its dependencies using the WPI (Web Platform Installer). Then we added additional features and extensions to the PHP deployment on Windows for IIS.

In this part I am going to demonstrate how to install PEAR and PHPUnit.

The Series

  1. Getting a Wordpress blog installed in a jiffy on Windows 7 using the Web Platform Installer
  2. Adding additional features to PHP
  3. Installing PEAR and PHPUnit
  4. Installing Eclipse PDT
  5. Configuring Eclipse PDT to work with Subversion source control
  6. Configuring Eclipse to work with Ant build tasks
  7. Creating a new IIS 7.5 fast CGI web site
  8. Setting up XDebug with Eclipse and IIS 7.5
  9. Setting up the Zend Debugger with Eclipse and IIS 7.5
  10. Configuring Ruby and Watir
  11. Moving a Wordpress blog from GoDaddy shared hosting to my local debugging system.

Go PEAR

Install Pear to gain access to additional PHP extensions like for example the PHP unit testing framework PHPUnit.

First start the CMD command prompt as Administrator and run Go-Pear.bat. The file is located in the PHP root folder. E.g. C:\Program Files (x86)\PHP.

Pear Installation_2

Figure 1: Run Go-Pear.bat as administrator

Just press enter to confirm that all the default paths are OK.

Installing Pear2_2

Figure 2: Confirm the default paths

Say Yes, if you allow access to the php.ini file.

Installing Pear3_2

Figure 3: Confirm access to the php.ini file

The following screenshot shows the files that PEAR installed.

NewPearFilesAfterGo-PearInstall_2

Figure 4: Files installed by PEAR

PEAR requires the setting of some environment variables that can be installed by merging the PEAR_ENV.reg file. Double-click it and it will merge the required registry settings.

RegisteringPearEnvironmentVariables_2

Figure 5: Warning about access to the Windows registry by PEAR_ENV.reg

Here is a screenshot of the registry merge script.

PearEnvironmentVariablesInTheRegistry_2

Figure 6: Registry merge script

Here is the complete text output of the PEAR installation session:

c:\Program Files (x86)\PHP>go-pear 

Are you installing a system-wide PEAR or a local copy? 
(system|local) [system] : system 

Below is a suggested file layout for your new PEAR installation.  To 
change individual locations, type the number in front of the 
directory.  Type 'all' to change all of them or simply press Enter to 
accept these locations. 

1. Installation base ($prefix)                   : c:\Program Files (x86)\PHP 
2. Temporary directory for processing            : c:\Program Files (x86)\PHP\t 
mp 
3. Temporary directory for downloads             : c:\Program Files (x86)\PHP\t 
mp 
4. Binaries directory                            : c:\Program Files (x86)\PHP 
5. PHP code directory ($php_dir)                 : c:\Program Files (x86)\PHP\p 
ear 
6. Documentation directory                       : c:\Program Files (x86)\PHP\d 
ocs 
7. Data directory                                : c:\Program Files (x86)\PHP\d 
ata 
8. User-modifiable configuration files directory : c:\Program Files (x86)\PHP\c 
fg 
9. Public Web Files directory                    : c:\Program Files (x86)\PHP\w 
ww 
10. Tests directory                               : c:\Program Files (x86)\PHP\t 
ests 
11. Name of configuration file                    : C:\windows\pear.ini 
12. Path to CLI php.exe                           : . 

1-12, 'all' or Enter to continue: all 
Installation base ($prefix) [c:\Program Files (x86)\PHP] : 
Temporary directory for processing [$prefix\tmp] : 
Temporary directory for downloads [$prefix\tmp] : 
Binaries directory [$prefix] : 
PHP code directory ($php_dir) [$prefix\pear] : 
Documentation directory [$prefix\docs] : 
Data directory [$prefix\data] : 
User-modifiable configuration files directory [$prefix\cfg] : 
Public Web Files directory [$prefix\www] : 
Tests directory [$prefix\tests] : 
Name of configuration file [C:\windows\pear.ini] : 
Path to CLI php.exe [.] : 

Below is a suggested file layout for your new PEAR installation.  To 
change individual locations, type the number in front of the 
directory.  Type 'all' to change all of them or simply press Enter to 
accept these locations. 

1. Installation base ($prefix)                   : c:\Program Files (x86)\PHP 
2. Temporary directory for processing            : c:\Program Files (x86)\PHP\t 
mp 
3. Temporary directory for downloads             : c:\Program Files (x86)\PHP\t 
mp 
4. Binaries directory                            : c:\Program Files (x86)\PHP 
5. PHP code directory ($php_dir)                 : c:\Program Files (x86)\PHP\p 
ear 
6. Documentation directory                       : c:\Program Files (x86)\PHP\d 
ocs 
7. Data directory                                : c:\Program Files (x86)\PHP\d 
ata 
8. User-modifiable configuration files directory : c:\Program Files (x86)\PHP\c 
fg 
9. Public Web Files directory                    : c:\Program Files (x86)\PHP\w 
ww 
10. Tests directory                               : c:\Program Files (x86)\PHP\t 
ests 
11. Name of configuration file                    : C:\windows\pear.ini 
12. Path to CLI php.exe                           : . 

1-12, 'all' or Enter to continue: 

*WARNING* 
We found php.exe under ., it uses an unknown SAPI. PEAR commandline 
tool has not been tested with it, if you have a CLI (or CGI) php.exe available, 
we strongly recommend using it. 

Beginning install... 
Configuration written to C:\windows\pear.ini... 
Initialized registry... 
Preparing to install... 
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.3.tar... 
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar... 

installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.0.tar... 
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.tar. 
.. 
installing phar://go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.2.1.tar... 
install ok: channel://pear.php.net/Archive_Tar-1.3.3 
install ok: channel://pear.php.net/Console_Getopt-1.2.3 
install ok: channel://pear.php.net/Structures_Graph-1.0.2 
install ok: channel://pear.php.net/XML_Util-1.2.1 
install ok: channel://pear.php.net/PEAR-1.9.0 
PEAR: Optional feature webinstaller available (PEAR's web-based installer) 
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer) 
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer) 

PEAR: To install optional features use "pear install pear/PEAR#featurename" 

****************************************************************************** 
WARNING!  The include_path defined in the currently used php.ini does not 
contain the PEAR PHP directory you just specified: 
<c:\Program Files (x86)\PHP\pear> 
If the specified directory is also not in the include_path used by 
your scripts, you will have problems getting any PEAR packages working. 

Would you like to alter php.ini <C:\Program Files (x86)\PHP\php.ini>? [Y/n] : y 

php.ini <C:\Program Files (x86)\PHP\php.ini> include_path updated. 

Current include path           : .;C:\php5\pear 
Configured directory           : c:\Program Files (x86)\PHP\pear 
Currently used php.ini (guess) : C:\Program Files (x86)\PHP\php.ini 
Press Enter to continue: 

** WARNING! Old version found at c:\Program Files (x86)\PHP, please remove it or 
be sure to use the new c:\program files (x86)\php\pear.bat command 

The 'pear' command is now at your service at c:\program files (x86)\php\pear.bat 

* WINDOWS ENVIRONMENT VARIABLES * 
For convenience, a REG file is available under c:\Program Files (x86)\PHP\PEAR_E 
NV.reg . 
This file creates ENV variables for the current user. 

Double-click this file to add it to the current user registry. 

Press any key to continue . . . 

c:\Program Files (x86)\PHP>

Go PHPUnit

Next we are going to install/deploy PHPUnit (3.4.10) using the PEAR delivery mechanism.

Go to http://www.phpunit.de/ to get the detailed installation instructions.

First, in an Administrator command prompt, type and execute the following three commands:

pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit.

Note: You will see the following PHP Error. I don’t know what it means yet. But it seems to be benign.

InvalidConfigurationDirectiveError_2

Figure 7: Invalid configuration directive error

InstallingPHPUnitWithPear_2

Figure 8: Adding the pear.phpunit.de channel connection and calling pear install

Here is the output.

c:\Program Files (x86)\PHP>pear channel-discover pear.phpunit.de 
Adding Channel "pear.phpunit.de" succeeded 
Discovery of channel "pear.phpunit.de" succeeded 

c:\Program Files (x86)\PHP>pear channel-discover pear.symfony-project.com 
Adding Channel "pear.symfony-project.com" succeeded 
Discovery of channel "pear.symfony-project.com" succeeded 

c:\Program Files (x86)\PHP>pear install phpunit/PHPUnit 
Did not download optional dependencies: pear/Image_GraphViz, pear/Log, symfony/ 
AML, use --alldeps to download automatically 
phpunit/PHPUnit can optionally use package "pear/Image_GraphViz" (version >= 1. 
.1) 
phpunit/PHPUnit can optionally use package "pear/Log" 
phpunit/PHPUnit can optionally use package "symfony/YAML" (version >= 1.0.2) 
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5) 
downloading PHPUnit-3.4.10.tgz ... 
Starting to download PHPUnit-3.4.10.tgz (254,536 bytes) 
.....................................................done: 254,536 bytes 
install ok: channel://pear.phpunit.de/PHPUnit-3.4.10 

c:\Program Files (x86)\PHP>

Symfony Framework

Besides PHPUnit I am also interested in installing the Symfony framework, which requires a ORM tool like Doctrine or Propel. I read that Symfony is best and most flexible deployed manually without using PEAR. In addition to that it already includes both ORM tools as part of its distribution.

Here is a screenshot of the deployed PHPUnit files and folders.

PHPUnitFolder_2

Figure 9: PHPUnit files in the Explorer

Ausblick

Now we are done deploying PHP core components. Starting with the next article I am going to focus on the development tools.

Tags: ,

Test Automation | Tips & Tricks | Php | Wordpress | WIMPinator Chronicles

Comments

12/19/2012 10:01:49 PM #

pingback

Pingback from siteduct.com

Script Installation Service

siteduct.com |

7/29/2013 9:02:35 PM #

pingback

Pingback from followliker.com

twitter automation software

followliker.com |

10/5/2013 3:07:25 AM #

pingback

Pingback from alexatrafficracer.org

Wine Lovers Guide

alexatrafficracer.org |

Comments are closed

About Klaus Graefensteiner

I like the programming of machines.

Add to Google Reader or Homepage

LinkedIn FacebookTwitter View Klaus Graefensteiner's profile on Technorati
Klaus Graefensteiner

Klaus Graefensteiner
works as Developer In Test and is founder of the PowerShell Unit Testing Framework PSUnit. More...

Open Source Projects

PSUnit is a Unit Testing framwork for PowerShell. It is designed for simplicity and hosted by Codeplex.
BlogShell is The tool for lazy developers who like to automate the composition of blog content during the writing of a blog post. It is hosted by CodePlex.

Administration

About

Powered by:
BlogEngine.Net
Version: 1.6.1.0

License:
Creative Commons License

Copyright:
© Copyright 2014, Klaus Graefensteiner.

Disclaimer:
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design:
This blog theme was designed and is copyrighted 2014 by Klaus Graefensteiner

Rendertime:
Page rendered at 4/19/2014 5:37:29 PM (PST Pacific Standard Time UTC DST -7)