PHP Frameworks are Governments

I was e-mailing a friend the other day talking about PHP frameworks. He’s been writing one for himself and I’ve written many many frameworks and CMSs through the years. I’ve also looked at a lot of existing frameworks out there like Zend, CodeIgniter, CakePHP, Solar, Symfony and I’ve come to a conclusion. There are a lot of similarities between PHP frameworks and governments.

If you don’t use a framework of some sort (I’m using a loose definition of framework) you would have anarchy. I’ve seen a lot of anarchy in PHP code. No consistency, code all over the place, probably insecure.

There are Libertarian frameworks, that provide some structure and common libraries but generally leave you to your own devices. They are lightweight, so they don’t use up too many resources and they are flexible. A Libertarian framework will probably not force you to use an ORM to connect to the database.

On the other end of that spectrum are the Fascist frameworks. They tell you how to lay out your code, how to write your controllers, how to write your templates and don’t even think about writing a line of SQL because you’ll be using ActiveRecord. These work because you don’t have to think much. Everything just works, you don’t have SQL injection problems, everything is filtered properly and forms are a piece of cake (as long as you don’t care how they look.)

Where does your favorite framework fall on the political spectrum?

  • We use Kohana, which is a PHP5 fork of CodeIgniter.

    I actually don't believe you need frameworks to survive, but since most of the web applications out there are intended to be built quick, almost everyone uses a web framework.

    If you listen to Cal Henderon's presentation at DjangoCon (http://www.youtube.com/watch?v=i6Fr65PFqfk), he mentions how Flickr wasn't built on any of these PHP-based frameworks. In fact, a lot of major sites (ebay, amazon, yahoo business, etc.) weren't built on any particular frameworks.

    Frameworks tend to "lock you in" to a particular mode of developing web applications. This can be a good and bad thing - good if you're trying to build on best practices, bad if it doesn't quite work the way you want it to.

    Boon
  • In a way I agree with you. I absolutely believe that when you are building a large web applications they have unique requirements that don't fit with any off the shelf web frameworks. However, just because you're not using an off the shelf web framework doesn't mean you're not using a framework. You would have just written a custom framework developed specifically for your application. I actually work for PBworks and we have a lot of custom code but lately in specific situations we're using the Zend Framework controller because for those parts it makes sense and fits the problem. We're not using any Zend database or session management classes or anything like that, because we've already written systems that do those things, we've already written our own framework that was specifically designed for those parts.
blog comments powered by Disqus