Wednesday, September 15, 2010

From Java to PHP - Impressions.

I am now gonna be working on PHP for the next few months. I have been tasked with bringing continuous integration into a set of products that my company is building. Because my last few years I have spent working mostly in java; I decided that before doing any thing about CI in these projects I will spend a few weeks working side by side with the other developers to gain and understanding of PHP as a language and more importantly, the mind set of seasoned PHP developers that have never had any interactions with things like CI, unit testing, continuous deployments and stuff like that. 
Today I just got my first PHP project up and going. It is a web app that exposes some rest end points. While getting it up and running I ran into a few problems as any one should expect but it was 1 particular problem that threw me for a loop. I Still can't find an explanation for it and if someone out there can explain it I'll appreciate it.
Here is how it goes. The particular code I was trying to execute was doing nothing; literally nothing, not even giving me an error message. After a few minutes of fiddleing around I got to a point in the code that looked like this:

} catch (Exception $e){
     echo $e;

So, the execute method was failing. The funny thing is that an error was being generated inside of it and the execution was completely halted; that is, no exception was getting caught in the catch block and the execute method was never returning. Now, I am new to PHP. I have previously worked with java, c#, javascript, c, c++, delphi and a few others I can't remember, and they all had predictable exception handling; so must likely there is something about PHP error handling that I am not quite grasping yet.
The problem turned out to be that I did not have the phpmysqli driver installed.