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.)