Just wanted to add a quick tutorial on setting up PHPUnit on your mac.

First step:
Mac osX no longer comes with PEAR (PHP Extenstion Aplication Repository) installed and this is the easiest way, in my opinion to install and set up PHPUnit. So the the first step is to install PEAR

Open terminal and run:

curl http://pear.php.net/go-pear.phar > go-pear.php

next run the script

sudo php -q go-pear.php

You will next be given a list of options. The only one that needs to be changed is the install dir
set it to /usr/local

Press enter and it will finish installing PEAR. Next you will need to alter the php.ini file used by the default install of php on the mac. Run the following:

sudo cp /etc/php.ini.default /etc/php.ini

next we need to add the pear repo to the include path.

sudo nano /etc/php.ini
press ctrl w and type in include_path
change this from ;include_path = ".:/php/includes"
to include_path = ".:/php/includes:/usr/share/pear"
//restart apache
sudo apachectl restart

Now pear should be installed. So onto the PHPUnit.

sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit

And that should be PHPUnit installed. So now onto netbeans. Fire up netbeans and then open prefrences -> php-> general and set the php interpretor to /usr/bin/php then go to unit testing and add /usr/local/bin/phpunit as your phpunit script. You may also want to add to your include path in netbeans /usr/local/share/pear/PHPUnit this will enable netbeans to read the class files and prompt you with auto completes.

Hope this helped.

  2 Responses to “Setting up PHPUnit on Mac with Netbeans 7”

  1. Hey Craig,

    brilliant piece of cake tutorial.



Sorry, the comment form is closed at this time.

© 2012 Craig Brookes Suffusion theme by Sayontan Sinha