Why Symfony2 is music to my ears...

Symfony2 has already been out a number of years so why write a blog post on it now? Well because its still in my opinion the best PHP framework out there.
In this post I will give my reasons as to why I am so fond of the framework.


Simple Installation:
Just clone the Symfony-Stanrdard app (found at Github).
Not only is it simple to install but comes with a Demo bundle (more info on that inside the Bundle section).

Comes with dev and prod environments:
Every application will require development and production environments and the fact that the framework is pre-built with different configurations saves on implementation time.

Profiler toolbar is useful and cool:
I know Zend Framework has one of these as well but its incredibly useful during development. Without much analysis in front of your face are all the performance metrics you could need. Easy to spot if something is not right.

Routing and Authorization done in annotations above controller-actions:
Symfony’s use of annotations is an elegant solution to what is a common problem. Attributing these 2 bits of information at the controller-action level is so tidy because really they are both tied to 1 page at a time. This way they are easy to read/find/update and do not warrent further configs (unlike Zend Framework).

Auto-updates Bootstrap if vendors are updated:
Symfony2 dynamically aggregates together all symfony components bootstraps into a single boostrap. Not only does this speed up the application but it creates a single source of truth for all Bootstrapping which can be very helpful for debugging.

These are wonderful self contained components. This produces an HMVC architecture. Each bundle relies on vendors/libraries autoloaded from the parent Symfony app. This means that each bundle has no dependencies installed within, just those listed inside its composer config. So they contain everything they require within. See best practices on more details on Bundles.
The standard Symfony2 app comes with the Demo bundle which is incredibly easy to remove.

Symfony2 makes use of PHPunit and their own DOM crawler they call Crawly. It is very fast and can parse markup for tests. Each bundle contains its own Tests and the Demo bundle even comes with feature and unit tests included for example. Very nice.

Built-in web server:
Some extremely useful meta-programming tools mean that not only can you run a web-server but also build Bundles with a few clicks.

Incredibly easy and tidy architecture:
Read below, need we say anymore.

app/: the application configuration, templates and translations;
src/: the projects PHP code;
vendor/: the third-party dependencies;
web/: the web root directory.

Commercially smart choice:
Produced by a company (SensioLabs) who aren’t going anywhere anytime soon. It is extremely well supported by a large community and finally its fully documented.

Some of the clean technical features:
- Nice dependency injection.
- PHPunit
- Behat
- Easy controller testing (functional test)
- HTTP client
- Event dispatcher (not always useful)
- Dom Crawler
- TWIG view engine
- ClassLoader
lots more

These are just a couple of reasons why Symfony2 is an elegant and performant PHP framework for any web application.
More to come in the future on PHP libraries and Symfony2

Leave a Reply