albertofem's blog

Personal blog about programming
cv - contact - github - twitter

What I have learned after one year of uninterrupted Symfony2 development

This past year I have been working with this framework, Symfony2, in a large-scale project involving several high-end technologies. We chose to use this framework to develop our base code because the team already had an expert PHP and other framework experiences. After a year of writing a lot of the code that the application currently uses, I can’t help but write some personal thoughts about it.

Why Symfony2 is the best PHP framework

Much has been said about this great framework. It is now safe to say that Symfony2 is the best PHP framework out there, for many reasons. I find the next the most important ones:

  • Community: I put this first on the list because I think it is one of the most important aspects of any open-source product, especially if you are using one within their proprietary applications where stability and support are critical. The Symfony2 community is very healthy; the framework itself has a very stable and trustworthy release model, very transparent and easy to keep up to date. Additionally, there are numerous custom bundles for everything you can imagine, and the quality of those is generally good.
  • Code quality: Symfony Components, the very core of Symfony2, have a high quality base code. And not just the code itself — but the architecture, the way things work, separation of concerns, DRY, etc. There are many good coding and design practices used across the system that make it simply beautiful and easy to understand. This is not surprise, knowing that many top PHP developers are involved actively in its development.
  • Encourages best practices: one of the best things about using this framework is that it encourages you to use programming best practices. Not just the specific quirks of PHP programming, but also well-tested design patterns, including service containers, database repositories, configuration files, dependency management, etc. I like to use these kinds of libraries not only for the intrinsic value they add to my own projects, but because it improves the overall quality of the final product itself, and of course, improves my coding skills as well.

Symfony2 isn’t for everyone

One of the things I realized after reviewing many frameworks is that they lack excellence. This is just a reflect of the real-world PHP programming scene: most of the developers out there lacks excellence too. If you think about it, the PHP framework scene just respond to what kind of developers make use of the language.

Symfony2 requires you to be exceptional in your work. It’s not easy to use framework; if you really want to take advantage of the coolest and most advanced features, you have to put it in the context of modern web application development. This means, you have to learn many other programs that comes in the ecosystem that makes Symfony2 really really powerful.

Let’s face it, most of developers out there doesn’t want to waste their time learning new technologies. Also, most of companies won’t waste any time modernizing their web technologies stack, and just want to get the job done. This is a shame for the programmers, because working in this kind of environment makes you by extension a mediocre programmer.

Ecosystem applications

Like a mention before, Symfony2 isn’t just the framework, it comes with many applications you should use to empower the framework. The intrinsic difficulty of this task relies in that you’re gonna have to learn how to use and work with another applications, and this can be a problem if your company doesn’t have the resources to put all that learning up front to develop the final application. Some of those applications include:

  • Composer: I can’t count how many times I have been stuck trying to resolve dependencies using Composer, the de-facto standard dependency manager in the PHP community. When you have many dependencies, Composer tends to be a little unstable and slow, things that have been certainly been improved with the latest releases. It seems that Composer just inherited the inherent chaos of the PHP community, though it’s becoming more and more organized with the time, something this program has helped to make.
  • Varnish: using Symfony without a proper caching is a web suicide in any case. Symfony is slow, although it’s architecture does a great job ease this part, it’s just not enough in any serious development. Varnish provides here a key element, and you’re gonna have to learn it properly, and trust me, this is no easy task. Maybe is the version chaos or the non-intuitive VCL language used to config the program, but learning it will sure give you some headaches.
  • Twig: another thing the framework comes with is the Twig template engine. Made by the community, this template engine is just awesome. It has many many features, it’s easy to use and very intuitive. The problem is, managing hundreds of templates, snippets, etc. can be daunting, and will go out of control very quickly if you don’t manage it well, in a way it makes sense.
  • Doctrine: I know, this ORM isn’t a mandatory use, but what is a modern web application without a database behind? Be prepared, Doctrine is a very complex ORM with a lot of features, but sometimes can be difficult to use, to really grasp the complexity it adds to your application, and debugging it can scare at times. It also adds an SQL dialect, called DQL, that is very needed to make advanced use of the repositories and so; another thing to add to the list of learning.
  • IDE: Managing an application that uses the Symfony2 way of doing things is very much impossible without an modern IDE. Whether it’s vim, PhpStorm or another one, you better learn to use it properly, and fast. You don’t want to get lose in the immense sea of classes you project will eventually turn into. My personal recommendation is PhpStorm, it just have any feature you can imagine, and more. Shame it’s made in Java.
  • Languages: not only programs you will have to add to your stack, but languages too. Proper use of Yaml, XML, annotations, and many other things I cannot bring to my memory right now.

Conclusions

Use Symfony in your applications, but first take some time to analyze your requirements and constraints, and then decide in the complexity and environment Symfony adds to your technology stack is really worth it.