Well, after my last rant/blog post I decided that its time to release some of our software as open source. When we build a site, I tend to prefer using a lean html/css front end and use Ajax to interact with the server. This can make for some fresh, dynamic sites and keeps page load times to a minimum. On the backed we try to keep things light, as this is obviously where you’re going to hit scalability issues so the more work that can be done on the client side the better.
On the backed you only really need a handful of classes, a basic controller to handle incoming Ajax request which then process these request, which generally just require database reads or writes. Each controller is generally different for each project, but follows the same principles and requires the same, simple, supporting machinery; database manager, session manager, logging and security/validation.
These classes give you a minimal layer of abstraction, making it easy to change infrastructure without making any code changes.
You could say this constitutes a php framework, albeit a modest one. But, its not really, as these are just helper classes that merely extend the base php functionality.
In the coming weeks, I’ll release all of these classes under GPL for anyone to play with, and welcome feedback.
So, I’ve just spend the last week getting to grips with the php framework symfony. Now, I understand the perceived benefit of using a framework to help speed up your development and save you from re-inventing the wheel.
I’ve been a developer for over a decade, and I’ve also been a manager too and now I run my own company. I always look for ways to save money by reducing the development overhead and leveraging pre-existing tech. But, I have never worked a project where a php framework has saved time or money. The possible exception is the wordpress framework, but that is because sites that are built from wordpress need a blog and a cms. That is a lot of overhead to build it out yourself, so it makes sense. But, it still takes longer to build out basic pages in wordpress then it would to hand code them in html/css with some ajax goodness. But, in the case of a simple site with NO cms and NO blog, then why the hell use a php framework? And wordpress is slooow. It takes some love to get a wordpress install running nice and fast.
I also build out server farms for my clients. So, I’m pretty clued up on how to build out fast sites on small budgets. Having 100% of a site rendered in php with lots of MySQL reads is definitely a bad start, I know there are plenty of ways to cache php and MySQL. Put a basic html/css site on a nginx server and watch it scream.
Anyway, back to symfony. Its just way too complex for what you need, its hard to maintain and not simple to upgrade. Ever been handed a symfony project from another developer? Yeah, its not all that nice. And multiple config files in multiple locations for a single website is also not a good selling point for a framework.
The number one rule in engineering is KEEP IT SIMPLE. Symfony violates that rule in so many ways, it adds complexity where complexity was not needed, and results in slower page loads. I like to keep it lean and mean.
I’ve spent so much of my career working with engineers who violate that number one rule on a daily basis, the often heard excuse is “I’m building re-usable code” or “this will make it faster to build next time“. Yeah, right. I met a highly successful VP at ITT, and he had a rule, “Write once, throw away“. This sounds crazy, but I believe him that its probably cheaper in the long run. Watch this video of a presentation by Ken Schwaber (the inventor of Agile project management), its interesting what he has say about the growth of infrastructure code and its effect on productivity.
So, what frameworks do I like for web development? Well, I love jQuery for one. This massively simplifies your code, and with the wealth of plugins life is made easy. And, the syntax is easy to read for the next developer who works on your code. It follows the KIS principle. Symfony does not.
I’m sure lots of people disagree with me on this, this is obviously just my opinion based on my own personal experience. But, figured it was worth sharing.