INSTALLING PHPUNIT FOR PHP 5.3 ON ZENDSERVER

ZendServer installs PHP CLI as part of the installation, and, as is customary for PHP 4.3+, includes a PEAR installer. It’s a good idea to install PEAR before installing PHPUnit as per the recommendation here.

  1. Open Zend\ZendServer\bin\go-pear.bat and change the line:
    %PHP_BIN% -d output_buffering=0 -d PEAR\go-pear.pharto (see PHAR Runtime Configuration):%PHP_BIN% -d output_buffering=0 -d phar.require_hash=0 PEAR\go-pear.pharThis will stop the fatal error:phar...does not have a signatureas by default PHP will not process a PHAR archive without a signature.
  2. Run go-pear.bat

    For Windows 7, make sure you open the console as an administrator, or the installer won’t be able to create some folders in the default install locations. At the command prompt enter:#cd \program files\zend\zendserver\bin
    # go-pear.bat
    and you should get something like this (I selected the system-wide install and accepted the default locations):install pear

    If the installation succeeded, you should see something like:end of pear install

    Note that c:\program files\zend\zendserver\bin is already in Windows Path, thanks to ZendServer.

  3. Update PEAR Trying to install PHPUnit at this point will fail, complaining of an outdated installer. Update the PEAR package:# pear channel-update pear.php.net
    # pear upgrade pear
  4. Add the PHPUnit channels – see Installing PHPUnit
    # pear channel-discover pear.phpunit.de
    # pear channel-discover pear.symfony-project.com
  5. Finally install PHPUnit# pear install phpunit/PHPUnitIf the installation runs successfully you should see:installing phpunit

You can check your PHPUnit by running it from the command prompt:# phpunit

——————

As of this writing I’m using Zend Server CE version 5.1.0 for my WAMP stack on a Windows 7 64-bit machine.  I was recently researching some open source tools that required PEAR yet for some reason I had not installed that yet.  The PEAR installation was fairly straight forward but there were a couple small detours.  I’ve documented my PEAR installation here for reference.

  1. Go to http://pear.php.net/go-pear, copy all of the contents on this page and save the file as go-pear.php in your C:\Program Files (x86)\Zend\Apache2\htdocs\ directory.
  2. Open your web browser and go to http://localhost/go-pear.php.  Click the “Next >>” link.  (NOTE: As of this writing the Go-PEAR installer is at version 1.1.6 and I’m installing PEAR version 1.9.4.)
  3. Set the Installation prefix ($prefix) field to C:\Program Files (x86)\Zend\ZendServer\bin\  (NOTE: Don’t forget the trailing slash “\” after bin.)
  4. Scroll down and click the Install button.
  5. After the PEAR installation is complete you need to add the PEAR installation path to your Windows “PATH” environment variables.  Right click on My Computer and select Properties.  Go to Advanced system settings -> Environment Variables -> under System variables scroll down to the Variable “Path”, highlight it, and click Edit.  At the end of this string add “;C:\Program Files (x86)\Zend\ZendServer\bin\PEAR”  (NOTE: Do not include the double quotes and be sure not to add a trailing slash “\” after PEAR.)  Click OK -> OK -> OK.
  6. Open your php.ini file with Notepad or any other text editor.  Your php.ini file should be located here C:\Program Files (x86)\Zend\ZendServer\etc\php.ini.  You need to add the PEAR path to the include path.[Zend]include_path=”.;C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library;C:\Program Files (x86)\Zend\ZendServer\bin\PEAR”
  7. Save your php.ini file and restart your computer.
  8. After your computer is restarted open up the command prompt.  On the command line enter “pear list” (NOTE: no double quotes)  You should see the stable version listed for your PEAR install.  If you don’t then you may be doing something different on your machine versus mine with regards to the installation.  Check all paths in this reference to make sure they are correct.
  9. If you’re getting a PHP Error “Invalid configuration directive” when running your pear command then you need to make a small change to your pear.bat file.  This file can be found in your C:\Program Files (x86)\Zend\ZendServer\bin\ directory.  Scroll down to the :RUN section and modify the line with the PHP directive “-d include_path”.  Add a “.;” before “%PHP_PEAR_INSTALL_DIR%” (NOTE: no double quotes)  So, your line should look like this “include_path=’.;%PHP_PEAR_INSTALL_DIR%’”.  Save your pear.bat file and rerun your pear list command.

… and that’s it.  You now have PEAR installed and can use all of it’s functionality.

If you thought this post was helpful and would like to give back to the community then click on the “Donate” button and make a donation. Thank you.

Advertisements

发表评论

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 / 更改 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s