Search

Rss Posts

Rss Comments

Login

 

Why I switched from CakePHP to Symfony2

Mar 30

I know there are tons of posts on blogs stating the difference between PHP frameworks. With this post I want to share my personal experience with two great frameworks, CakePHP and Symfony2, and why I made the switch.

I’ve been working with CakePHP for over 2 years. In my current position I was forced to learn CakePHP, and because it was the only framework I know, I did all my projects with it. Altough not a bad framework, it has a few shortcomings. I recently had the opportunity to start working with Symfony2, which I wanted to learn for a long time. So why did I choose to switch from CakePHP to Symfony2? There are many reasons that I can point out, but I want to outline the most obvious and important aspects. Maybe in a later post I will go into much more detail.

PHP 5.3
The most obvious point would naturely be Symfony’s extensive use and support for the latest version of PHP (including version 5.4). The use of namespaces makes extending the framework and core classes very easy. A framework needs to be up to date with the latest technology, and Symfony makes sure you can use the latest version of PHP with all the added benefits with any project. Of course it can be downside if your server is still running on PHP 5.2, but I would strongly suggest any one to upgrade to at least 5.3, and update all existing projects to be compatible.

Flexibility
With Symfony, you have the flexibility to customise any core functionality with ease, without the worry to override core classes. You are not limited to using any specific ORM or templating engine, and can easilly add your favourite classes or libraries with ease. And a bonus is the decoupling of components that Symfony provides, so you’re not even limited to using the whole framework, but can use any component in your existing application.

Doctrine
With every great framework and application you need a decent database abstraction layer and ORM (Object Relational Mapper). Symfony comes bundled with Doctrine, which in my personal opinion is the best ORM available for PHP, but it also offer support for Propel, another great ORM. Again you are not limited to using any specific ORM, but you can integrate your favourite one without too much hassle. And this is also a very big downside of CakePHP in my opinion, as the default ORM feels very slow and outdated, and it still use arrays instead of objects for all entities, and integrating a custom ORM is too much of a hassle to be even worth it. Also Doctrine has support for NoSQL databases like MongoDB out of the box, where CakePHP needs extensive configuration and 3rd party plugins to add the needed support.

Twig
Symfony comes bundled with the amazing templating engine Twig, which makes the creating of your templates a breeze. You also have the option of using any other templating framework that you wish. But with template inheritence, automatic escaping and the custom filters you can create, I couldn’t imagine that you would want to use anything other than Twig. Altough there are plugins available for using Twig with CakePHP, it still requires a degree of customization and isn’t as flexible as using the bundled solution that is packaged with Symfony.

Bundles
One of the strongest points of Symfony is the use of bundles. A bundle is what most other frameworks will call a module. It lets you group a specific set of code or functionality together, that you can either plug into any other Symfony project, or just keep some functionalty seperate from other parts of the application.

I barely touched the surface on why Symfony2 is my new framework of choice. If you ever considered learning Symfony2 but were unsure, I would strongly suggest you jump straight at it. Hopefully in a next post I can go into a lot more detail and show you the true power that Synfomy2 provides

3 Comments

Add your comment

  1. [...] some time I started working with another framework…Behold Symfony2If you read my post about why I switched from CakePHP to Symfony2 (and you definately must read it if you haven’t), then it would come as no surprise that I [...]

  2. Zach Smith
    Jun 26 at 19:53

    this was actually informative – not like most of what i see online. sharing :)

  3. Zach Smith
    Jul 01 at 17:11

    Way cool! Some extremely have valid points! I appreciate you writing this article, also really good

Post a comment

*

 

Page optimized by WP Minify WordPress Plugin