On July 28th Symfony2 was finally released, with launch parties all over the world. Developers are excited, managers are excited and whole ecosystem is happy. They’re right, there are plenty of reasons to be optimistic. symfony 1.x is a great framework, I made many  projects with it, nevertheless Symfony2 is a new way of doing things in PHP. I observe, that applications made with symfony 1 tends to be messy with raising number of functionalities. There too many magic tricks, which you can use, which are hard to manage in big, multi-team projects. Symfony2 does it smarter.

Dependency Injection Container for the rescue

The common problem in big application I’ve seen made with symfony1 was that developers made services, manager classes, helpers all over the code. Some were in main lib/, others in applications lib/ and sometimes you can find those in modules lib/ folders. With a big volume of project, finding proper class wasn’t so easy. Symfony2 uses Dependency Injection Container, which unifies access to main services, which is awesome for me. This approach is used broadly in Java and .NET world, and now Symfony has it.

Mess in templates is over

symfony1 came out with templates written in pure PHP. That was good, because eliminates templating engine overhead and was handy for PHP developers to use their functions. But believe me or not – 90% templates I’ve seen disappointed me. I even saw „helper functions” on top of templates and Doctrine calls… Symfony2 by default uses Twig Templating engine (PHP templating is still available). Twig is fast and easy to read and develop. It offers inheritance model, and provides many points of extensions. Twig is very similiar to Django templating engine, which is one of best I used.

Reusable code out of the box

Bundles systems is the core concept of Symfony2 project. Inner mechanisms, third-party plugins and your code is organized into the bundles. They are easy to work with, and can be moved between applications without a big effort. Other nice concept are Components which are core of the framework. Components are independet and can be used outside of Symfony2 (for example in batch processing or even building own framework).

Doctrine2

Doctrine2 is bundled in the Symfony by default. It offers ORM layer, as well as MongoDB mapping. Doctrine is also rewritten from the scratch and impresses its speed and new approaches on data accessing. Doctrine extensively uses annotations (other parts of Symfony2 do it as well), which Java and C# developers knows well and which is very good  way of keeping metadata configuration in one place.

That’s not all

There is many more awesome features like:

  • full PHP 5.3 support (namespaces, closures, etc.),
  • new forms component,
  • standalone validators,
  • brand new security layer,
  • PHPUnit by default,
  • assetic for static assets management,
  • code generators,
  • huge amount of third party bundles (http://symfony2bundles.org),
  • Git repository hosted on the github.com
  • and of course great community.