Why you do not need a heavy-weight PHP framework

This post is (not) for beginners.

Recommended reading:

Rasmus Lerdorf: PHP Frameworks? Think Again.

What is Symfony 2?
(I am not a Symfony fan.)

You don’t need all that by Marcel Esser
“… The point I am trying to make is we’re getting a little crazy with our architectures. …”

An Overview of PHP Framework Guides for Developers
(Surely, this is not a new topic.)

My Reasons:

* I have been writing PHP/SQL/HTML/CSS/JavaScript code for over 10 years; I have seen enough codebases, wrappers, abstraction layers, frameworks: Most advanced PHP developers like doing it their way; hence PHP world has “thousands” of frameworks.

* When you use a framework, don’t forget that they come with their own issues. Your backward compatibility and upgrade routes concerns are in the hands of others!

* PHP has enough magic! It is fast and light-weight especially if you use autoloading.

* I made fanatic developers see how their beloved MVC frameworks such as Zend, Symfony, Doctrine and custom XML-based ones suffer under heavy load.

* Even the light frameworks such as Yii have many layers of classes; everything extends CComponent! Zend Framework claims to be component-oriented but it is like Linux dependency hell! If you don’t believe me, check its memory footprint for a simple hello world page! It must not be 4MB with Zend! It is normally 500KB.

* It is worth looking at this benchmark if you want to serve millions of visitors:

* You can easily gather the best ideas from other PHP frameworks and do it yourself better, because the programmers share their ideas, methodologies and design patterns in the open source world, even between programming languages.

* Your application will probably be complicated and heavy enough, so you do not need a heavy framework, loading thousands of lines of code on every single request!

* There are fundamental design flaws, logical errors even on the popular frameworks. For example, Zend Framework forms: you do not need to load all the form elements, definitions and validators when showing the form and handling the form post. Validators are used only when the form is posted. Also, the form elements are not needed when the form is posted. You should not load all the validators at once; you can load them one by one and return error message on the first validation error; this way the request is handled quickly using less memory.

* Similarly, database layer in Zend Db is using schema information frequently and causing heavy record objects.

* I don’t like messy code, and I love PHP’s autoloading feature. When I see so many lines of “use” statements in Symfony 2; it reminds me Java and my stomach hurts! When I see Python-like request handling in (lightweight) Silex it reminds me someone unaware of PHP’s magic!

* When I see “buggy” Doctrine 2 suggesting the code should generate/upgrade a database, and recommending primary keys composed of only ONE column; I ask: “Hang on a minute, who is the programmer here?!”

* Many developers agree that we should write fast and scalable applications in the first place; e.g. caching should not be a requirement, just like fast CPUs and more RAM; Microsoft’s lazy programmers did that for many years: “You need to upgrade!”

2 thoughts on “Why you do not need a heavy-weight PHP framework

  1. Take a look at Zend Framework 2.0.0. Was released a week or two ago. Completely different from version 1.12. We are using it with Doctrine 2, Composer, PHPUnit, Puppet and Jenkins.

Leave a Comment