essays / Back to the Basics

Back to the Basics - Turning on the LAMP.

Why handicapped? In the days of django, Rails, numerious MVC frameworks and ORMS that take much of the lower level database and routing out of building websites, why would someone go back to plain old PHP and SQL?

My reasoning is going back to plain PHP and SQL would make me better appreciate and understand MVC design and working with raw SQL queries – not fleeing from them. Moreover, due to the more OOP oritened nature of PHP5 that is avilable on most webservers –pritcularly hared servers - A.K.A. the classic LAMP stack (Linux, Apache, MySQL, and PHP) for web development would make deployment and installation much easier than a custom install requiring a virtual or dedicated server and worrying about scability, etc. I took up a challange to write fairly good code in PHP while keeping the good design, code seperation and clear organization.

Coming back to PHP was nice at first due to an easy install and no need to reload the code on the development server after making a change. However, the nice parts of the switch pretty much ended there. In an attempt to keep everything lean, I chose limonade as a simple PHP router and sinatra-like framework to clean up the admin routing and rendering MVC code while writing my own database model (using __call and PDO). Now, it’s nice to know more about .htaccess files and regex that I had not known starting out.

One of the hardest parts about not using a framework was the freedom and restraint required to keep well-organized and clean code. Something I really missed from the other programming languages I’ve been working with recently (javascript, Python, and ruby), was the lack of good OOP inheritance and not being able to declare a function as a variable. This sevely limited metaprogramming and increased variables being passed around. Hopefully, this can be cleand up while I work on the basic ORM layer I've written for this. Right now, it uses __call to wrap a function in another class that generates PHP with parameters and sanitizes the arguments then executing the query. I might rewrite this using varable bindids and dynamic __get callers, but until then…

Overall, the journey has continued as expected, but the total control of the database schema and queries and how the queres get passed to the final page have bene interesting – things I’ve taken for granted with MVC frameworks and ORMs. I’m trying to keep the project lightweight and organized. I hope I’m succeeding – and if so – keep it that way.

(see rough draft, 2nd draft p1 p2)

(comments on hacker news)