I have been developing with PHP for about a year now, and whenever an unexpected result comes out, I normally do something like echo $var; or var_dump($var, $some_var);. If the error occurred on a production site, I might have remembered to add something of an IP Checker to ensure that it only appeared on my own computer.¬ This approach to testing led to some embarrassing outputs when I uploaded a file to production to find a hidden var_dump(); in some obscure function called once in a while.

About 3 months ago, I knew that there had to be a better approach and I had heard some of my friends who use other languages talk about Unit Testing. I learned that Unit Testing merely provided a set of automated tests for the smallest piece of testable software. This seemed like a miracle, I would save so much time by letting my computer run my code and check rather than me manually checking it in the browser. It seemed like a great idea, and so I started researching similar testing extensions available for PHP. I discovered the automated testing framework PHPUnit. I started trying to figure out how it was supposed to be used, and I got lost in all of the steps, requiring me to use a multitude of different tutorials and gave up. It seemed to me that to get all of these things working I needed to use a *nix machine.

I recently decided to give it another try and now have now figured out how to install PHPUnit on Windows. So this is a guide for all of you wondering how to start testing with PHPUnit on Windows 7. I imagine that the steps required for other versions remain roughly the same.

So first open a command prompt window. And type in the following

php -v

you should see something along the line of

PHP 5.3.4
Copyright 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright 1998-2010 Zend Technologies
    With Xdebug v2.1.0, Copyright 2002-2010, by Derick Rethans

If you have everything installed correctly, if this is the case (it was not for me) you can skip ahead to Installing PEAR. If not and you get a message such as:

’php’ is not recognized as an internal or external command, operable program, or batch file.

We need to add the PHP executable file to your system path.

First we need to find your PHP executable file, so open up the start menu and search for php.exe and instead of clicking on it use a right click and open file location and copy the location from the new explorer window.

No head over to Start > Control Panel > System > Advanced > Environment Variable and in the list of system variables scroll down until you see Path and append


where C:\path\to\php is the location you copied from the previous step. The executable is now in your path, now try opening a new Command Prompt and type in php –v it should work now.

Now we are going to install PEAR. PEAR is “The PHP Extension and Application Repository” it is “a framework and distribution system for reusable PHP components.” PEAR is required to install the required components of PHPUnit. PEAR allows PHPUnit to install all of its dependencies rather than asking you to go out scouting for it. So point your browser to http://pear.php.net/go-pear.phar and save that file somewhere easy to find. Now using a Command Prompt navigate to your downloads folder — for those of you new to the command line interface on windows you can change directory by entering

cd C:\path\to\pear\download

and you can see the files in a directory by typing in dir followed by enter. Once you are at the correct directory type in

php go-pear.phar

followed by enter.

The installer should now be running, it will be asking you a few questions about how you’d like the PEAR Package to be installed. Most of the questions are straightforward (such as if you are doing a system wide install or a local install). After that it will ask you about the file layout for your PEAR installation. These are the preferences that I decided to go with, it is easiest to type in all to edit.

  • Option 1 (alias $prefix): Installation Prefix — This is base location for all of your files for PEAR, I decided to go with something simple C:\pear.
  • Option 4: Binaries Location — Binaries actually mean PHP scripts, shell scripts and so on. This directory will need to go into your systems path variable (using the same procedure I outlined above). I decided to go with the normal convention of a \bin directory for all binaries. So enter $prefix\bin.
  • Option 11: Name of Configuration File —The default location for this is inside your C:\Windows directory. I wanted to move it so that all PEAR related files were in the same directory and did not have to worry about loose files so I entered $prefix\pear.ini. Wherever you decide to place this file, you need to remember that it is looking for the name of a file not just a directory
  • Option 12: Path to CLI php.exe — This is the location for php.exe, we can use the copy and pasted value from above when we added the directory to our path. PEAR auto populates this value with the PATH value from above, but like Option 11 it requires the name of a file so I put in C:\path\to\php\php.exe

We are almost there; the Installer will attempt to modify your php.ini file. If you have WAMP installed there is a good chance that it will auto-detect the incorrect php.ini file, as WAMP does not use the php.ini file located in the php bin but in the Apache Bin. So open up the correct php.ini file, if you have WAMP just click on the icon and navigate to `PHP > php.ini` and at the end you need to insert the following

include_path = ".;c:\pear\lib" ;

Once you finish inserting that, save the file and restart Apache.

Once again navigate to Start > Control Panel > System > Advanced > Environment Variableand in the list of system variables scroll down until you see `Path` and append


now we have PEAR installed.

Now we can install PHPUnit, this is when it gets easy. Open up a new command prompt and type in `pear channel-discover pear.phpunit.de`. This tells PEAR to add this channel to its list of PHP projects to search. Now that has to be done only once. Okay we are finally installing PHPUnit, type in

pear install –a –f phpunit/PHPUnit

this will install PHPUnit and all of its dependencies.

Now we can start using PHPUnit to test our PHP Scripts. So I’m copying this test unit’s PHPUnits’ website. The only difference is that instead of `require_once 'PHPUnit/Framework.php';` we need to `require_once "PHPUnit/Autoload.php";`. Now everything should work.

require_once "PHPUnit/Autoload.php";
class ArrayTest extends PHPUnit_Framework_TestCase {
    public function testNewArrayIsEmpty()  {
        // Create the Array fixture.  $fixture = array();
        // Assert that the size of the Array fixture is 0.
        $this->assertEquals(0, sizeof($fixture));

    public function testArrayContainsAnElement() {
        // Create the Array fixture.
        $fixture = array();

        // Add an element to the Array fixture.
        $fixture[] = 'Element';

        // Assert that the size of the Array fixture is 1.
        $this->assertEquals(1, sizeof($fixture));

Now I was trying to test PHPUnit in the browser, but I would see nothing happening. In order to test a PHP script with PHPUnit you need to open a command prompt and type in

phpunit C:\path\to\script

So if I run the test script supplied by PHPUnit I can see that it had no failures. However if I change line 25 to

$this->assertEquals(2, sizeof($fixture));

I get the following message when I run the PHPUnit test.

PHPUnit announces that there was a failed test and describes the error, that we had created. This approach to testing seems to be easier, and in the future I plan on showing you how to write your own tests with PHPUnit.

Every time I open my Gmail email inbox I am reminded of how many email’s I have not opened, how many I plan on writing and how many were caught in Google’s spam filter by a little notification counter next to each folder.  When I see these numbers I have to click on them to see what I have missed since my last visit. I cannot stand those numbers being high because it means that I have forgotten to respond to someone or take action on a task.

These unread counts also appear in various other contexts’ such as in RSS readers and even in Facebook.  Every time I would log onto Facebook the unread counts next to my messages, and groups and applications I had to click on them similar to my email inbox. My feelings of guilt and that I am missing out on something carried over from my email inbox unread count to those on Facebook or my RSS reader. This would mean that every time I logged onto Facebook I would spend hours clicking those unread counts just to make them disappear.

I felt that this was a ridiculous waste of time, and I started to visit Facebook less often so I wouldn’t have to deal with that tiny counter as often. I then realized that as a programmer I could come up with a quick solution to hide those counts and hopefully remove the guilt entirely. I installed Stylebot a Google Chrome extension and added a new CSS rule to remove these pestering counters.

.uiSideNavCount {
    display: none;

As soon as I enabled this CSS rule I noticed that I started to spend less time on Facebook but my overall experience on the site changed. Previously visiting Facebook  while intended to be a distraction from work, became a bore because I had to get rid of each of the unread counters, now my visits to Facebook are shorter by I am much happier because I feel I can stop browsing any time I wish to.

Last week my friend played against Horace Mann, and I had the chance to take some shots, here are some of my best ones.

On Friday January 20th, The Horace Mann Record published a modified version of  my argument against SOPA. I encourage you to check this article out.

[UPDATE 1/16/2012 16:35]: SOPA has been pushed back! However, I urge everybody to not take this concession as a victory, and continue arguing against legislation similar to this one across the globe (for example the “Sinde law” in Spain) and even PIPA in the U.S. 

We have grown up with the internet, the freedoms associated with it, and a culture where access to almost the complete accumulation of human knowledge is accessible to all for the benefit of all.  It is difficult for me to watch legislation being enacted that if passed could harm innovation and stifle creativity.

The Internet has changed our world by fostering freedom of speech and thus, by giving a voice to those whose voices has been traditionally suppressed; from Cairo to Tripoli, people’s lives have been transformed because of it. But the internet has also brought unintended consequences; intellectual property theft has flourished — now believed to take up 23.76% of all internet traffic. As such new laws are constantly introduced to discuss the protection of intellectual property online, the newest of which is the Stop Online Piracy Act H.R. 3261 (SOPA).

SOPA aims to combat online piracy by allowing individual corporations, to shut down access to foreign websites in US jurisdictional areas “dedicated to the theft of US property”. Although in principle the idea behind SOAP is noble, it will burden internet corporations with onerous levels of liability for all user-generated content while blurring the distinction between the site’s owners and its users, similar to criminalizing the private operators of a toll highway when drivers travelling in the highway commit a crime.  Under SOPA, sites could be punished for not policing their site for copyrighted content, even if owners do not post anything illegal themselves. This bill may force internet corporations to spend more money on compliance and litigation than on innovation. Smaller sites and startups that cannot afford such compliance burden or long legal fights may be fatally impacted.  Facebook, twitter, reddit, Wikipedia, and google aren’t going away because of this bill; however, the next facebook, twitter, reddit, or Wikipeida will. The internet has fueled the innovation economy injecting over 2 billion dollars into the US economy according to President Barack Obama, if SOPA were passed, future engineer entrepreneurs may not have a chance. I believe that there must be laws to regulate copyright, but they should not attempt to change the fundamental structure of the internet, such as the OPEN Act.

I remember my first website: a simple ecommerce website that listed products on a static page. It was created in 2000 on Microsoft Word, I was 8yrs old, and it was never uploaded on to my server. 9 years have passed since then and very little has changed. I know how to create beautiful code, my geekiness has grown factorial-ly, and I’m now 2.75 times taller. However, most of my projects are never taken off of my local machine. I recently looked at the complete contents of my sever and I saw 75 unique designs that do not share anything even the copy. All of them about 80% finished. I started to think about why almost all of the contents of each folder were left alone for so long, and it hit me: I hated them. I had created 75 unique portfolios because each one sucked, not in the conventional connotation, but because each of them sucked in relationship to what could have been. Each of these portfolios could have been: prettier, more usable, and more semantic. I created an unsurpassable bar, and there was no choice but failure.

After my realization I decided I needed get rid of the portfolios. I needed a clean start. I was going to try something new. I wasn’t going to be perfect, I was going to be good enough. I was going to put the minimum about of work into it. I told my friend about my folders, and my plans and he laughed and said that I was going from one side of the spectrum to the complete opposite. But I wasn’t, I wasn’t going to stop at the pure minimum, but I was going to stop as soon as I had something usable I was going to upload it and make it public. However, I wasn’t going to stop there, I would continue to work on it and build another release. This seemed rather simple but my desire to perfect every last function, pixel was almost impossible to suppress. It took me a while to understand that I needed to put something out there so it could be used and it could be refined.  I did some searching and learned about The Done Manifesto and I am going to try to adopt these principles in all of my works:

  1. There are three states of being. Not knowing, action and completion.
  2. Accept that everything is a draft. It helps to get it done.
  3. There is no editing stage.
  4. Pretending you know what you’re doing is almost the same as knowing what you are doing, so just accept that you know what you’re doing even if you don’t and do it.
  5. Banish procrastination. If you wait more than a week to get an idea done, abandon it.
  6. The point of being done is not to finish but to get other things done.
  7. Once you’re done you can throw it away.
  8. Laugh at perfection. It’s boring and keeps you from being done.
  9. People without dirty hands are wrong. Doing something makes you right.
  10. Failure counts as done. So do mistakes.
  11. Destruction is a variant of done.
  12. If you have an idea and publish it on the internet, that counts as a ghost of done.
  13. Done is the engine of more.
I always teach people who I work with that you have to prototype first and often, but I often get lost in my own projects and forget this simple fact. Perhaps following these principles will allow me to take my own medicine.

When you first think about winter one normally thinks about snow. Those small crystalline ice particles disguise the world around us and seem to hide the imperfections. However as I looked at the recently released images from NASA’s Earth Observatory and saw the following (click on the image to see larger):

I realized that the while snow is often associated with winter in the Northern Hemisphere.I did a bit more research by overlaying longitude and latitude on the maps and saw that most of the snow was located above the 40N line as seen below. Therefore it would seem by symmetry that it should also snow beneath the 40S line. However since there is very little land mass beneath this line and the warm maritime environment, snow occurs only in elevated regions.

This would seem to be the reason that there is very little snow in the southern hemisphere. Its interesting to see that misconceptions I never thought I had exist and that the opposite can be true. What are some of your favorite misconceptions?