Installing PHPUnit with Zend Server (CE) on Windows using PEAR

After a few hours of trying to figure out what was failing each time, I think I’ve finally found the solution (which is a combination of various other tidbits of information I’ve picked up from other blogs)

Firstly, assuming you’ve got a stock installation of Zend Server or Zend Server CE, it will be installed at:

C:\Program Files\Zend\ZendServer\

Therefore the PEAR setup batch file will be located at:

C:\Program Files\Zend\ZendServer\bin\go-pear.bat

If you run this from the command line (go to the bin directory then type “go-pear”) it will prompt you with the setup configuration for PEAR. The prompt will look something like this:

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.

The issue that was causing my installation in particular to fail (which is not an issue with say XAMPP or other bundles) is that Zend Server installs by default to your Program Files directory, which has a space in it. PEAR doesn’t play well with spaces, so you will need to change your Temporary directory for processing and Temporary directory for downloads to something without a space such as C:\Temp or C:\tmp

Type “all” to change them all and simply enter replacement paths for the temporary directories, then hit enter when re-prompted. This should install PEAR and create a Registry file for you to merge (it will say where it created it, which should be in the same directory you just ran go-pear.bat in)

Type “pear” at the command line to see if it installed properly. Once it’s working OK type the following:

pear channel-discover
pear channel-discover
pear channel-discover
pear update-channels

This will add the channels that contain the packages required by PHPUnit (you’ll need all 3) then updates all available channels

pear upgrade pear

This will upgrade PEAR in case it is not up to date.

pear install --alldeps phpunit/PHPUnit

This will install PHPUnit from the correct channel with all the dependencies it requires (which is what the Symfony and eZ Component channels are needed for)

The problems I encountered which aren’t covered elsewhere is the fact that PEAR will fail trying to download and install packages if you don’t change the temporary directories, and that without the additional channels (not just the PHPUnit channel) it doesn’t seem to be able to work out where the dependencies are even though it knows they are required.