LAMPlights Personal anecdotes from my experiences using the LAMP stack

5Jul/100

The Bug Is In Your Code

I stumbled across this while reading some tweets: http://bugs.php.net/bug.php?id=52198.  This reminded me of something I was told while attending a programming workshop at college: over 90% of the time the bug is in your code.  At the time I didn't think about this much as I had been writing code for only about 6 months and assumed the third party libraries I was using were bug free.  As I continue to grow as a developer and engineer, I am amazed at the number of developers immediately blaming the library or framework they are using for a bug in their project.  Bugs do exist in all code, but it is more likely that the bug is in your code.

Tagged as: , No Comments
5Jul/100

Learning To Use MongoDB

I have heard of MongoDB for some time and have read quite a few articles and attended some conference seminars about it.  I had put off using MongoDB because I could find no project that really made good use of it.  About two weeks ago I started a project that doesn't really fit into the relational database mold.  I finally had the perfect excuse to devote the time and effort to learning all about MongoDB and take my place among the ranks of developers using NoSQL (whatever that means).

19Apr/100

Don’t Overuse Use

Nate Abele just announced Lithium 0.9 on the rad-dev blog.  I think Lithium is a great looking framework and can't wait for it to get a 1.0 release and really start to take off.  However, looking through the examples I started to notice that the use of the "use" namespace keyword was an often used convention.  It reminded me of the require/require_once creep of the days of old.  I was discussing it with Nate via Twitter, but I couldn't seem to get my point across.  Maybe I will have better luck here...

20Mar/103

Using Absolute URL’s In The View

We recently had a project at work that involved replacing all the relative URL's from the application with absolute URL's. In the past, developers had just hard-coded an absolute URL only when they need to force the browser over to https. Now we are using multiple subdomains, so this approach is no longer sufficient. We also wanted a way to easy rotate assets through multiple CDN URL's to speed up the time it takes a user's web browser to load all the content.

15Mar/103

PHP 5.3 is the new JavaScript (almost)

In my last post, I argued that the best way to start developing functional PHP applications was to code review some JavaScript projects.  I think this is a good place to start as most web developers have written some JavaScript at one point during their career.  I briefly mentioned that the array is pretty similar to the JavaScript object too.  However, if you start hacking away at PHP based on JavaScript's functional syntax, you will quickly run into some problems.

13Mar/1010

PHP goes functional in version 5.3

It has been said that all languages, over time, implement a dialect of lisp.  PHP appears to be no exception. 

8Feb/100

Mocking Zend Framework’s Row and Rowset objects

If you separate your business logic from your data access logic, the last thing you want to do is make your business logic unit tests reliant on the database.  This is normally not a big deal: retrieve the data, store it in an array and pass it off to the class with the business logic.  Mocking the data for the unit test simply requires you to hardcode from array information in the test.  However, I recently ran into a case where I wanted to pass Zend_Db_Table_Row and Zend_Db_Table_Row objects to the business logic and mocking them was not so easy.

6Feb/100

Logging Exception Traces To syslog

If you have ever visited StackOverflow.com you may have noticed the ads for Splunk.  Splunk aggregates log files together and provides a web interface to search through those logs.  The setup for php is easy: set the php.ini error_log value to "syslog".  The Splunk instructions show you how add a single line to your syslong.conf to have syslog send those messages over to Splunk.

5Feb/100

Canonical Version Numbers with Git

Brandon Savage wrote a controversial blog post about why subversion is still more relevant than git.  His main point was that enterprise requires canonical version numbering to track progress in the application and that git cannot do this.   There was a lot of debate about this on Brandson's, but a recent comment by Morgan proved Brandon wrong.

17Jan/104

Unit Testing and the Law of Demeter

I was writing some code today and not using Test-Driven development.  The reason was that I did not have a good understanding of what I was writing, so I decided to write some of the guts before writing the tests.  In the process of writing the guts, I recognized that I was paying very close attention to how I was going to later test each of the methods I was writing. I was paying especially close attention to the Law of Demeter.   The idea behind the Law of Demeter is to keep units of code distinct from one another. So how did this relate to my code?  To put it simply, my business logic methods did not use get methods.