Skip to content

Categories:

Installing PEAR, cURL, Selenium, and PHPUnit on Windows

These are some rough instructions having gone through the process.  I’ll update and refine these if I ever do it again.  Feel free to leave some comments with additions/corrections.  Make sure you have PHP installed first.

Install Pear

NOTE: YOU CANT HAVE ANY SPACES IN YOUR PATH TO PHP AND PEAR.  THEREFORE, MAKE SURE PHP IS NOT INSTALLED IN THE “Program Files” DIRECTORY OTHERWISE YOU WILL NEVER GET PEAR WORKING FROM THE COMMAND LINE.

  1. Download PEAR
  2. Extract the archive using WinRAR
  3. Create a “PEAR” directory in  C:\PHP
  4. Copy the contents of the PEAR-x.x.x directory to the PEAR directory you just created
  5. Download Console Getopt, Archive Tar, and Structures Graph
  6. Create the directory c:\PHP\PEAR\Console.  Unzip and copy “Getopt.php” from the Console Getopt zip file into it.
  7. Create the directory c:\PHP\PEAR\Archive. Unzip and copy “Tar.php” from the ArchiveTar zip file into it.
  8. Create the directory c:\PHP\PEAR\Structures. Unzip and copy “Graph.php” and the contents of the “Graph” directory from the Structures Graph zip file into it.
  9. Edit your php.ini and add your php PEAR directory to your include_path
  10. Edit your system environment variables as follows:
    • PHP_PEAR_BIN_DIR = C:\PHP\PEAR\scripts\
    • PHP_PEAR_INSTALL_DIR = C:\PHP\PEAR\
    • PHP_PEAR_PHP_BIN = C:\PHP\php.exe
  11. Add C:\PHP\PEAR\scripts to your “Path” environment variable
  12. Run a command prompt as Administrator
  13. cd to C:\PHP\PEAR\scripts
  14. Create a pear.ini file in c:\Windows.  Alter the permissions so that any user can write to and modify it.
  15. Run the following commands:
    • pear config-set auto_discover 1
    • pear config-set bin_dir c:\PHP\PEAR\scripts

Enable cURL

  1. Copy php_curl.dll from the php “ext” directory to the Windows System32 directory
  2. Edit php.ini and uncomment the line that references the cURL extension.

Install PHPUnit

  1. You need to install specific versions of PHPUnit components if you are running Zend Framework 1.x (see: http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/).  From the administrative command prompt you opened earlier, run the commands:
    • pear channel-discover pear.phpunit.de
    • pear install --alldeps --force phpunit/PHPUnit
    • pear install phpunit/DbUnit
    • pear install phpunit/PHPUnit_Selenium
    • pear install phpunit/PHPUnit_Story
Install Java JRE
  1. Download JRE
  2. Install it as normal
Install Selenium
  1. Download Selenium Server
  2. Create a directory called “Selenium” in C:\Program Files\Java\jre7\bin
  3. Copy the file you downloaded in step 1 into this directory.  It should be called “selenium-server-standalone-x.xx.x.jar”
  4. Create a new MS batch file called Selenium.bat on your desktop.  Inside, type the command
    • java -jar "c:\Program Files\Java\jre7\bin\Selenium\selenium-server-standalone-2.25.0.jar” (note: Include the quotation marks and substitute the version number for the version you downloaded)

Download a PHP webdriver library

  1. I like the Facebook one: https://github.com/facebook/php-webdriver

Run Selenium

  1. Execute the bat file you created for Selenium above.  This will lauch the selenium service that will listen for incoming commands from your test scripts.

You’re now ready to write PHPUnit tests using the PHP webdriver library. This library will talk to Selenium via the port that it opens (4444) when you run the batch file.

 

Posted in Uncategorized.