Skip to content

Get Coverage Reports working with PHPUnit and MAMP

If you get a “The Xdebug extension is not loaded. No code coverage will be generated.” error message when running phpunit –coverage-html test, you need to add Xdebug to the php.ini as follows:


The actual path may actual be different as I am using ActiveState’s Komodo version of Xdebug that I manually copied to the PHP extensions directory.

If you are running MAMP Pro you should also add the above lines to the php.ini template. Do this by opening MAMP Pro Application and click “Edit Template” from the File menu, then click “PHP 5.3.6 php.ini”.

Save and restart your servers.

PHPUnit 3.6 Tests and Komodo IDE Unit Testing

The latest version of PHPUnit, which at the time of this writing is 3.6.3 breaks the Komodo IDE Test Plan feature due to the wrong PHPUnit include in the drive_testrunner.php file.

My php_error.log file had the following:

Fatal error: require_once(): Failed opening required 'PHPUnit/Framework.php' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in /Applications/Komodo on line 16
require_once() /Applications/Komodo

All that I needed to do was to edit the file /Applications/Komodo and replace the outdated

require_once 'PHPUnit/Framework.php'


require_once 'PHPUnit/Autoload.php'

right at the top and now all is working.

If your tests stil don’t run under Komodo set the PHP interpreter to the MAMP binary in the PHP Languages Properties in the Komodo Preferences.
In my case /Applications/MAMP/bin/php/php5.3.6/bin/php.

Happy testing.

If you’re having problems in getting PHPUnit to work in the first place check my other article to get PHPUnit to work with MAMP on Mac OSX Snow Leopard and Lion.

MAMP 2.0 Pear and PHPUnit Installation

I have been struggling to get PHPUnit working under MAMP 2.0 on OSX Lion, and Snow Leopard. After a lot of searching and googling, and combing through countless forums I figured it out and my tests are finally running.

Here are the steps I took for MAMP using PHP 5.3.6, if your PHP is different adjust accordingly, but basically you have to be in the bin directory of MAMP’s PHP install. If you are you should see the binary for php, for pear, in this directory.

cd /Applications/MAMP/bin/php/php5.3.6/bin
sudo ./pear upgrade pear

In my brand new, fresh, install of MAMP i got the following error:

Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.

If you get this error as well just delete the pear.conf file, and rerun the pear upgrade

rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
sudo ./pear upgrade pear

You should now see something like (truncated the output for space):

downloading PEAR-1.9.4.tgz ...
Starting to download PEAR-1.9.4.tgz (296,332 bytes)
.............................................................done: 296,332 bytes
downloading Archive_Tar-1.3.8.tgz ...
Starting to download Archive_Tar-1.3.8.tgz (17,995 bytes)
...done: 17,995 bytes
downloading Console_Getopt-1.3.1.tgz ...
Starting to download Console_Getopt-1.3.1.tgz (4,471 bytes)
...done: 4,471 bytes
upgrade ok: channel://
upgrade ok: channel://
upgrade ok: channel://

Now that you’ve upgraded Pear you can install PHPUnit and its dependencies. Following instructions from the PHPUnit Github repository, i.e. directly from the developer, you can install PHPUnit by running:

./pear config-set auto_discover 1
./pear install --alldeps

DO NOT RUN ./pear install phppunit as that will install some old and useless version that will not work! There are a lot of tutorials out on the web that are outdated and will not work for the latest version of MAMP and PHPUnit.
You should get something similar to the following (truncated for space):

Attempting to discover channel ""...
downloading channel.xml ...
Starting to download channel.xml (804 bytes)
install ok: channel://
install ok: channel://
install ok: channel://

Notice that PHPUnit_MockObject and PHP_CodeCoverage are also installed.
You are now ready to run phpunit and see if it works…


Should print usage information without any errors, on the screen your your PHP Error log file. If there are any include errors in you PHP Error file, you may have multiple PHPUnit versions installed and you need to remove them all by using the pear uninstall command.

My php_error.log had a bunch of entries that looked like this:

PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/MockObject/Autoload.php' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Autoload.php on line 48
PHP Warning: require_once(PHPUnit/TestCase.php): failed to open stream: No such file or directory in /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit.php on line 49

To resolve this I uninstalled all PHPUnit, and PHPUnit_MockObject.

./pear uninstall phpunit
./pear uninstall
./pear uninstall

Then reinstalled PHPUnit as explained earlier in this article.

One final comment on Using PHPUnit in your tests. A lot of the tutorials I found on the web, including the PHPUnit manual tell you to include PHPUnit in your code as:

require_once 'PHPUnit/Framework.php'

For the version at the time of this writing which was PHPUnit 3.6.3 you must do the following instead

require_once 'PHPUnit/Autoload.php';

Happy testing!

Jailbreak the Internet Browser on your Sharp Aquos

Just got a new Sharp Aquos LC-52LE830U and I am really happy with it!

The only problem is that Sharp decided to lock you out of a full Internet browser experience, and only give you access to a very limited set of Widgets. Not to sure why but definitely not a very consumer friendly policy. I just hate this new trend where manufacturers arbitrarily limit the functionality of the products we spend top dollar on.

Geting out of the Sharp Aquos Net jail is easy enough and will not damage your TV in anyway. In reality you do not have to change anything on the TV it self but as usual do this at your own risk and responsibility.

The basic idea is to use the bookmark feature to add a Bookmark to Google or any other page of your liking, so it is always accesible. From there you can then access any site you like.

Unfortunately the TV browser does not support Flash so no Youtube…

You will need:

  • DNS Server (this can be done on your Internet router, Mac/Linux or Windows computer)
  • Web Server

Install webserver on your laptop. I used MAMP on MAC OSX

    1. Create the sharpaquos folder on the web server root (/Applications/MAMP/htdocs/sharpaquos in my case)
    2. Create the widget_split.php file in the sharpaquos folder with the following content
<script language="JavaScript">
 if (window != top) top.location.href = location.href;
<a href="">Google</a>

Highjack one of the Aquos Net widgets by redirecting the DNS name resolution to your webserver

    1. We need to redirect to the webserver in my case
    2. I added a the DNS Zone to my Fortigate, and configured it as follows:
    3. Add the host and point it to the webserver
    4. Press the Aquos Net button on your TV remote, and access the Access Holywood widget, mine was on page 4.
    5. You should see the “Google” link inside the widget instead of the regular Access Hollywood widget content.
    6. Navigate to the Widget and Google should open on the full page, and not restricted to the inside of the widget.
    7. You can now bookmark the Google page by pressing the “D” button on the TV remote
After you successfully bookmark google you can remove the DNS redirect configuration from your Internet router.
Now you can acesss Aquos Net like always and use your “Get out of jail” Google bookmark to break free any time you like!

“There’s no App for that” should be RIM’s catch phrase for the Playbook

Thanks to my beautiful wife and daughter I got a Blackberry Playbook for Father’s Day. We already have an iPad and they thought the sharing was becoming a burden on the family…
Knowing that I am a BlackBerry person she decided to buy a Playbook instead of another iPad.

The initial setup was easy, but the first signs of trouble came when it connected to RIM to check for new updates.
The Playbook determined that there was a new version on the server, and started downloading it. The file was over 300 MB and the Playbook lost Wifi signal several times, delaying the download considerably.

I noticed that when the Playbook was flat on my desk the signal went down by a couple of bars, not as bad as the iPhone 4 but noticeable, and enough to cause the connection losses. So there I stood with the Playbook in hand until it finally downloaded the update file. It stared installing it, and after did a reboot. At this point I unplugged the device and went out.

Like any other Black Berry the Playbook takes FOREVER to boot, and when it was finally done it wanted me to connect to Wifi network and would not do anything else, or give me any option to continue. I was basically locked out!

So there I was stuck with a fresh new device searching for any open wireless network I could connect to. When I did find one, all the Playbook did was to give me a message thanking me for the upgrade. Well done RIM. Strike 1 – First impression: not good!

The second nightmare was installing the Blackberry Bridge software on my phone. I’m told by the Playbook that I need to go to the App World on the phone and download it, it even gave me a convenient QR code which, once scanned, opened the App World app on the phone. Easy. I was beginning to feel happy again, I could see my self doing all my corporate email, using my BBM, you know all that we love about our Blackberry phones.

That was not to be. Unfortunately, and to my utter amazement, AT&T does not allow RIM to provide the Blackberry Bridge app to its subscribers, and all I got was message saying that I was SOL!
Strike 2.

Now lets think about this for a moment. AT&T does not let RIM use messaging, calendar, BBM, and all the applications and services we love the Blackberries for. Why do I need a Playbook for?

As a consolation prize the Playbook came with 2 pre-installed games Need for Speed and Tetris. The first time I ran the Blackberry world app it told me that these needed updating so I clicked the button. Big mistake! The NFS download was almost 300MB and the Playbook kept loosing Wifi connection, so it took over 2h and several failed attempts to get that update installed.

That brings me to my last point, THERE’S NO APP FOR THAT!
Once running the Playbook is easy on the eyes, I liked the interface a lot, flash websites worked fine, but other than that there’s very few things to do with it. There are so few apps on the App World for the Playbook that the only parallel would be to compare it to the vast emptiness of the outer space. The claim that the Playbook runs Android apps had me excited, so I looked for a way to install the Android Market app so that I, at least could try those out, but no… no sir, RIM added one final hurdle to overcome. Developers need to submit their Apps to RIM so that they can approve, and add them to the Blackberry World.

Strike 3. The Playbook went back to the shelf at Best Buy.

Clearly this is a half-baked device, much like their recent phones, with a lot of limitations, installation problems, bugs (some pre-installed app for online video kept crashing) and above all no Bridge, ie, nothing Blackberry for AT&T subscribers.

The combination of very few consumer apps, and the inability to use the enterprise apps for which Blackberry is known for will kill this device faster than you can say Steve Jobs!

Clean your Apple Mighty Mouse Scroll Ball

The scroll ball in the Apple Mighty Mouse is an essential piece of mouse hardware and it gets clogged often. When it does scrolling tends to become erratic and difficult, to the point where it stops completely. I use this method to clean the ball without opening the mouse. Trust me when I say you do not want to open the Mighty Mouse…

  1. soak one Q-tip in alcohol, not dripping wet, you do not want to drown your mouse
  2. start rubbing the Q-tip over the ball in all directions and notice that you’ll start to see dirt come to the top
  3. gently rub off the dirt, or use a dry Q-tip to get it out.
  4. repeat process until the ball is totally clean

Hope this helps. If you have no time, no Q-tips, or no alcohol, just press the ball down hard, and scroll it. Do this a few times and whatever is stuck will become free and you’ll usually regain scrolling right away.

Cassandra Development Environment in Mac OS Snow Leopard

I just started working with Cassandra so I am no expert on the subject, and this post is more about self documentation of what I did to get it working on my laptop, running Snow Leopard, than an expert’s How to guide. If it helps you out all the better, and leave your comments.

Getting Cassandra to run on Mac OSX is very easy just download the latest binary from At the time of this writing the version was 0.6.3, but I updated the important parts to 0.7rc3 so it should work with that version as well.

Create the directories Cassandra needs to work:

sudo mkdir -p /opt/cassandra
sudo chown -R `whoami` /opt/cassandra
sudo mkdir -p /var/log/cassandra
sudo chown -R `whoami` /var/log/cassandra
sudo touch /var/log/cassandra/system.log
sudo mkdir -p /var/lib/cassandra
sudo chown -R `whoami` /var/lib/cassandra

Get Cassandra and copy it to /opt/cassandra. In this example I used wget. Notice that the version numbers may change so use the correct link for your version from

tar xzf apache-cassandra-0.6.3-bin.tar.gz
cd apache-cassandra-0.6.3/bin
./cassandra -f

If all is ok you should now see

INFO 22:01:15,273 Auto DiskAccessMode determined to be mmap
INFO 22:01:15,887 Saved Token not found. Using 114412163776176127313248360017471199843
INFO 22:01:15,888 Saved ClusterName not found. Using Test Cluster
INFO 22:01:15,898 Creating new commitlog segment /var/lib/cassandra/commitlog/CommitLog-1278036075898.log
INFO 22:01:15,937 LocationInfo has reached its threshold; switching in a fresh Memtable at CommitLogContext(file='/var/lib/cassandra/commitlog/CommitLog-1278036075898.log', position=419)
INFO 22:01:15,946 Enqueuing flush of Memtable-LocationInfo@1373164447(169 bytes, 4 operations)
INFO 22:01:15,954 Writing Memtable-LocationInfo@1373164447(169 bytes, 4 operations)
INFO 22:01:16,262 Completed flushing /var/lib/cassandra/data/system/LocationInfo-1-Data.db
INFO 22:01:16,295 Starting up server gossip
INFO 22:01:16,406 Binding thrift service to localhost/
INFO 22:01:16,414 Cassandra starting up...

Now lets test Cassandra. Open a new Terminal window, or tab, and:

cd /opt/cassandra/bin
./cassandra-cli --host localhost --port 9160

Cassandra 0.7rc3 output and testing is a bit different so check with the comments bellow.

At the prompt (for 0.6.x)

cassandra> set Keyspace1.Standard2['jsmith']['first'] = 'John'
Value inserted.
cassandra> set Keyspace1.Standard2['jsmith']['last'] = 'Smith'
Value inserted.
cassandra> set Keyspace1.Standard2['jsmith']['age'] = '42'
Value inserted.
cassandra> get Keyspace1.Standard2['jsmith']
(column=age, value=42; timestamp=1249930062801)
(column=first, value=John; timestamp=1249930053103)
(column=last, value=Smith; timestamp=1249930058345)
Returned 3 rows.
cassandra> quit

If you’re able to get the values out of Keyspace1 all is good and Cassandra is up and running.
If you are installing 0.7 or higher the test Keyspace1 is not loaded automatically and you need to run jconsole to load the “schema”. And go to MBeans -> org.apache.cassandra.service -> StorageService -> Operations -> loadSchemaFromYAML as documented on LiveSchemaUpdates

Please note that jconsole needs to connect to localhost on port 8080, to talk to Cassandra. Do not use the Thrift port 9160.

Now lets install Chiton, a GTK GUI written in Python that will allow us to view the data stored in Cassandra.

mkdir chiton-temp
cd chiton-temp
git clone git://

In order to fulfill a Chiton dependecies we also need

  • Twisted 8.1.0 or later
  • Thrift (latest svn)
  • PyGTK 2.14 or later
  • simplejson
  • Telephus

First download and install Apple’s Xcode if you don’t have it already then, get a PyGTK Mac OS build  from

Copy PyGTK to /Develper as instructed in the README.txt of the PyGTK package.

Now for each of the packages, except Thrift run

sudo python install

If you want to use Python 2.6 run

sudo python2.6 install

Compiling thrift. Go to the directory to which you checked out Thrift from the SVN
Because of the time it may take to compile all the updates, you may skip the
port selfupdate and port upgrade outdated. But if you start getting compilation errors you MUST do them and wait 😦
My iMac took 5 hours!!!

sudo port selfupdate
sudo port upgrade outdated
sudo port install boost pkgconfig libevent
cp /opt/local/share/aclocal/pkg.m4 ./aclocal
aclocal --acdir=./aclocal
./configure --with-boost=/opt/local --with-libevent=/opt/local --prefix=/opt/local
sudo make install
cd /opt/cassandra/apache-cassandra-0.6.3/interface/
thrift --gen py:new_style cassandra.thrift
cp -a ./gen-py/cassandra ~/chiton-temp/

(thank you Rich for the configure details

Almost done!!!
All we need to do is add the PYTHONPATH to our ~/.profile. Using your favorite editor open ~/.profile and add:

export PYTHONPATH=/usr/lib/python2.6/site-packages/:/Developer/MacPyGTK/inst/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/thrift:/Library/Python/2.6/site-packages/telephus:~/chiton-temp/chiton
export JAVA_HOME=$(/usr/libexec/java_home)

The directories in your PYTHONPATH may be a bit different, but the idea is to add all the directories where all the packages we just installed are located. If you miss one you will get import errors when running chiton-client.

Reconfigure Cassandra to allow the Thrift connections from Chiton, you need to set ThriftFramedTransport to true in cassandra’s storage-conf.xml. In my system

vi /opt/cassandra/apache-cassandra-0.6.3/conf/storage-conf.xml


If all is well you should now be able to run chiton-client. Login to localhost on port 9160. Don’t forget to have Cassandra daemon running (cassandra -f).

Since we changed the Thrift access to framed, from now on if you want to use the cassandra-cli don’t forget the –framed command line option. Cassandra 0.6.3 daemon crashes with:

ERROR 23:50:24,264 Uncaught exception in thread Thread[pool-1-thread-5,5,main]
java.lang.OutOfMemoryError: Java heap space

if you don’t use –framed.

Hope this guide helps you get your development machine ready to work with Cassandra.