PHPUnit

Add PHPUnit to MAMP 2.x, including PHP 5.4.4 for OSX 10.8

December 3rd, 2012 0 Comments

delete: /Applications/MAMP/bin/php/php5.4.4/conf/pear.conf
(delete or bak)

$ /Applications/MAMP/bin/php/php5.4.4/bin/pear channel-update pear.php.net
$ /Applications/MAMP/bin/php/php5.4.4/bin/pear upgrade pear
$ /Applications/MAMP/bin/php/php5.4.4/bin/pear channel-discover pear.phpunit.de
$ /Applications/MAMP/bin/php/php5.4.4/bin/pear channel-discover pear.symfony-project.com
$ /Applications/MAMP/bin/php/php5.4.4/bin/pear install phpunit/PHPUnit

make available in terminal:
$ mv /Applications/MAMP/bin/php/php5.4.4/bin/phpunit /usr/local/bin/phpunit

test:
type phpunit –version in Terminal
(you will see latest version of PHPUnit).

Note, if you need an older version of PHPUnit, like 3.6.x, you will indicate that when installing phpunit/PHPUnit-3.6.12

How to install PHPUnit on Mac OSX

October 18th, 2012 0 Comments

The de facto standard unit testing framework for PHP is PHPUnit. You can find it here (GitHub repository). Even if the documentation explains how to install it on your system, it may not be as self-explanatory as it looks. Here is a little how-to for Mac OSX.

Get PEAR.
Open a Terminal window and type :

curl http://pear.php.net/go-pear.phar > go-pear.phar
This will copy the file we need to install PEAR on your local hard drive, in your User directory.

Install PEAR.
Still in Terminal, type :

sudo php go-pear.phar
Change the installation path (option 1) to

/usr/local
and launch installation.
After installation has completed, you can safely delete the go-pear.phar file.

Tell PHP CLI where PEAR is.
By default, PHP CLI (Command Line Interface) php.ini does not exist, but a template is available on the system. We have to copy and edit it. Type :

sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini
Uncomment the include_path line and make it look like this :

include_path = “.:/usr/local/share/pear”
Tell Terminal where PEAR is.
To let Terminal know where is your PEAR path and be able to launch PHPUnit right from the console, type (in the console) :

sudo nano /etc/profile
and add

export PATH=$PATH:/usr/local/bin
to the end of the file.
Save and exit. Close your Terminal window.

Install PHPUnit.
Open a new Terminal window and type :
sudo pear config-set auto_discover 1
sudo pear install pear.phpunit.de/PHPUnit
This will install all needed files for PHPUnit to run.

Enjoy.
Everything should be fine. In your Terminal, type :
phpunit
You should get a list of all available PHPUnit functions. Happy testing !

Setup Xdebug with Zend Server CE

January 20th, 2012 0 Comments

Open Zend Server page, http://localhost:10081/

Disable “Zend Debugger”

Download xdebug.so binary which I suggest to download at -> http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging

Extract the archive and browse into ’5.3′ folder then copy ‘xdebug.so’ to ‘/usr/local/zend/lib/php_extensions’

Open ‘/usr/local/zend/etc/php.ini’ and add the following lines above [zend] section:

zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
xdebug.show_local_vars=On
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20

Now restart your Zend Server by ‘sudo /usr/local/zend/bin/zendctl.sh stop’ and ‘sudo /usr/local/zend/bin/zendctl.sh start’