Why Symfony?
Fabien Potencier
September 07, 2012
Yesterday, Zend Framework 2.0 and Symfony 2.1 were released... almost at the same time. First, I want to congratulate the Zend Framework team for this huge milestone; I know that working on a new major version is no small task.
And of course, people started to ask questions about these new versions and one of the most popular was: "Why would I choose framework X over framework Y?". As you can imagine, the answer is not that easy as each framework has its own specificities.
I like to think that most popular frameworks are modular enough, fast enough, well-documented enough; they are using well-known design patterns. So, besides the buzzwords, what is unique to Symfony? Why would you want to use Symfony instead of X (replace X with ZF, CakePHP, Lithium, Laravel, Slim, Yii, you name it)? That's the question I'm going to answer in this post.
So, without further ado, here are my main selling points for Symfony:
Symfony is not a framework but a project. Depending on your needs, you can choose to use some of the Symfony Components, the Silex micro-framework, or the full-stack framework.
Symfony is used by many large companies (like the BBC or CBS), by many large websites (like TED, wetter.com, Lockers or even YouPorn just to name a few) and some Open-Source projects are also powered by Symfony (CMSes like Drupal or eZpublish, libraries like PHPUnit or Doctrine, products like phpBB or shopware, and even frameworks like PPI or Laravel). This brings a lot of interoperability between all these solutions.
Symfony enjoys a huge community of users and contributors; during the last year alone, 550+ people contributed to the Symfony core and the community created over 1,600 bundles for the full-stack framework. Symfony also has several annual dedicated conferences around the world and a large number of user groups.
Symfony has been created in 2005 and here to stay. Besides SensioLabs, many other companies rely on Symfony for their clients and they contribute, invest money, and sponsor the future of the project.
Symfony embraces the "don't reinvent the wheel" philosophy, and provides tight integration with many other Open-Source projects (like Monolog, Assetic, Doctrine, Propel, ...).
Symfony tries to bring innovation to PHP: it was one of the first major frameworks to embrace PHP 5.3, to introduce the usage of a Dependency Injection container, and to use a templating engine for its templates by default, Twig, which is now also adopted by major CMSes like Drupal and eZpublish. Symfony also has some unique features like its gorgeous debug toolbar and its great built-in profiler.
If you think I've missed some important selling points, feel free to list them in the comments and in a few days, I will aggregate everything in a new page that will be hosted on symfony.com to help users make an informed decision when choosing a framework.
And if other frameworks would like to do the same, I would happily add links to their pages on the Symfony one, and if in turn, they do the same, that would create a ring of links that will ease the choice of a PHP framework for developers.




Discussion
Great post, cause its based on facts and doesn't bash others.
Regards Dominik
- ZF2 components are OK to use without the framework itself.
- No doubt that ZF2 will be used by many large companies and OpenSource projects. Since both ZF2 and Symfony2 are PSR-0.
- ZF2 community is large as well. Contributors are very good. Conferences are there. I know no PHP conference when there are no ZF talks (or ZF mentioned in talks).
- Zend is definitely here to stay.
- ZF2 brings innovations same as SF2.
The CLI is a good example what is almost completely missing in this list: features.
Community, age (as in mature and here-to-stay), stability, etc.: almost every framework is going to list that, it doesn't really make the framework special. Why not focus on which innovations really make Symfony special from a coder's perspective. The central philosophy when it comes to code and structure, things like that...
Other than that, it's a cool attempt. I hope other frameworks are going to jump in with their lists.
Anyway, feel free to create the same list for Zend Framework as it would help people choose their frameworks more easily. If you list most of the things I've listed here, that's fine too. I didn't said that Symfony was the only PHP framework to have these characteristics. Keep in mind that PHP has hundred or event thousands of frameworks. So, of course, similarities exist between them.
I'm not really into Zend Framework, just checking what's happening on the PHP scene from time to time, so I'd better leave building of the pros list to people tightly working with it.
What do you think about Symfony2, ZF2 and the niche these frameworks are now taking?
It's all marketing, witch looks just like Fabien was afraid that ZF2 will pull out some users from Symfony community.
Why Symfony, should be a post about what makes Symfony 2.x so special, why developing application with is different (better? easier?) that in ZF2. And all I see is that Symfony if good because... it it good. Not a single argument for a developer wondering witch framework: ZF2 or S2.1 to choose.
Symfony1 vs ZF1 or Symfony2 vs Zf1 is quite easy to say why Symfony might be better for most projects and developers. With ZF2 some of those arguments are not valid any more and it would be interesting to read what Fabien thinks about it, how Symfony make life easier and help build projects faster/better than Zf2.
So far I don't see any reason why Symfony should be better for my project than ZF2, and after creating 1 site in SF2 and looking at tutorials of ZF2 - I guess I will go along with ZF2, it fits into my needs better than SF2.
So, Fabien, Why Symfony, Why... ?
And if we want to start talking about features, that's also something we can do, but that was not the goal of this post.
Then again, I don't want to start a flame war between Symfony and Zend Framework. There are many other good frameworks around that you can choose from too.
It's been 8 month since I do my stuff with Symfony exclusively. I couldn't be happier.
My selling points:
- ZF2 is too "scientific". You can right a thesis about ZF2 and its design. Don't get me wrong, I love best practices, standards, design patterns etc, but ZF2 devs dive to deep into "science". It is like Minix Vs Linux if you will.
- Symfony's components on the other hand are pragmatic set of tools to get the job done, while embracing same standards/patterns/etc. Routing Vs Router, HttpFoundation Vs Http, Translator Vs i18n to name a few. It just feels easier to use, debug and get the job done. Each time I dive in sf code I wonder how simple and elegant the solution is with arguably less code than for same feature in zf.
- "don't reinvent the wheel" philosophy is not just a bullet point. Thanks to Symfony I discovered so many great libs I've never heard of being in zf ecosystem: Assetic, Imagine, Behat, Twig, Composer, Silex, Monolog Knp stuff and many more.
- I think it is much easier to find a high quality bundle for Symfony than for ZF module/component (I'm referring to zf1 here, obviously zf2 needs to catch up). Almost for any task there is a bundle you can base your stuff on or at least to get an idea how to approach the problem.
- I wrote this above, but can't ignore the existence of Symfony\Component\Form. I never used Zend\Form. It was a pain in the ass. A HTML mess in PHP trying to decorate my output. Not sure what zf guys have now, but I can't leave without sf's form any more.
- CLI tools. I know ZF2 has its own console component now, but look how much stuff is out there on github using Symfony\Component\Console.
Since ZF2 packages are available via composer now, I use both, but sf will remain as the framework I base my stuff on.
Bundles, yes, for ZF2 they (modules) are about to be created, but so it was for SF2 when it was developer or just released (but I guess right after the release there were already some very nice bundles for SF2).
But it's a matter of time, within a year this might not be true and what, there will be no real arguments for a developer wondering ZF2 or SF2?
And I really would like to read what you think about that, Why Symfony and not ZF2. With ZF1 it was really easy to say, not it's not so obvious.
Or, maybe putting this in other words: What do you (Fabien) think of ZF2: could they done more, go in some other direction? I guess that actually this is the kind of question that will give me an answer to Why Symfony.
good post, and this is what I like to read in blog post about Why Symfony. Thanks anonymous :)
Have great peoples and community.
Domain driven design
SF2 switched to Git/Github before ZF2 and this speeds up development of SF2. Also this shows contributing Symfony2 is more easier than ZF to me. (Especially for SVN days of ZF1)
Still SF2 components still more loosely coupled than ZF2.
SF2 brings to annotations and Composer to PHP framework world. This is a huge bonus point.
KnpBundles, Twig, great bundles, libraries..
Don't go trashing frameworks when you are completely ignorant of them.
http://modules.zendframework.com/
This is exactly the idea of open source in the enterprise IMO. Share the bits that are not business critical, re-use some others if you can, and build your secret awesome sauce on top of it for your core product.
The other advantage of "componentization" is that if some new third party lib comes about that kicks ass, you can easily replace the one you used and move on. On the other hand if a new third party lib comes to compete with some component you have in the framework, most likely you won't ditch that component (as a framework author). Of course the framework users are still free to replace the component with NewShinyLib, but if it is not done at the core, it means less people will benefit from it.
Go with Rails, Django, hell, even build your own in Go
You can't expect a Mercedes-Benz advert to include information on BMW products, can you?
[/irony]
Replacing framework component is hardly possible not because framework developer doesn't want it but because extensions and projects are already actively using it. Offering to choose a component yourself isn't a good thing too. There will be lots of third party code written using different components doing the same thing.
"Why would you want to use Symfony instead of Z? That's the question I'm going to answer in this post."
did you not understand? Sounds like he's comparing against Zend to me.
Since composer entered into the PHP scene, thinking that "I won't use framework X because I use framework Y" is not something applicable.
You just require `symfony/console` and `zend/event-manager` and `propel/propel` and `doctrine/mongodb-odm` all together... See? It works!
So let's think about building things WITH symfony, not "only with" symfony.
Fabien, you should also stop using the word "instead", that just limits the scope of action of the end user ;)
http://www.youtube.com/watch?v=4ex9UIfQ2Aw&feature=plcp
most of them choose Symfony2 because ZF2 wasnt here at the time.
All my friends learned Symfony through Jobeet, it was really great documentation. For newbies, but also with very deep insights.
And also al my friends use a lot the admin generator. The new one from Sonata has exceptional features, but it's not ready out of the box and also is not as well maintained as the framework itself.
As my opinion, Symfony Components are great for many purposes, but the full-stack framework isn't as complete as it was on Symfony1.
This is an awesome idea. To drive it further, why not try to introduce an informal standard?
http://[project-site]/pitch
e.g.,
http://symfony.com/pitch
http://framework.zend.com/pitch
http://cakephp.org/pitch
...
And alas, we could do the same...
http://drupal.org/pitch
http://ez.no/pitch
http://www.joomla.org/pitch
...
:)
Lastly, I somewhat agree with a few others here that some of the maturity/marketing/community arguments are not really unique. But then again, you can easily ignore them in your evaluation. (and also, sorta along the lines of: if they need to list that to get the page filled... others might have listed more important things ;))
Anyway, I think this is a fantastic idea. And nothing prevents us + everyone else from just doing and trying it. :)
so, what's make Symfony2 great for me is:
+ Form component: it's a very important indice
+ Coding style like in others languages
+ PHP5.3
what make Symfony2 also great is the innovation he has done in this language, and also the inspirations of other languages ??like Python and Ruby
i think the challenge is the chalenge started by fabpot in this post: http://fabien.potencier.org/article/64/php-is-much-better-than-you-think
The documentation is fantastic as well. I read the docs in a weekend and completely understood the framework after.
I used to use Zend FW a long time ago and it was great, but I have to say SF2 is my favorite framework to develop on. It forces me to develop clean testable code. And the community is there to help.
@fapbot: Thanks for building this stack! (And thanks to all the contributors as well)
http://blog.evan.pro/why-zend-framework
* the form component in 2.1 is awesome
* integration with phpunit
* twig changed my life
* some great bundles like JMSI18nRouting, FOSUser, LiipImagine, LiipFunctionalTest
* I love the decoupled approach
* dic
And composer, which is not directly related to sf but is already there to be used. And it'a a game changer.
Because those two apparently aren't really the same thing as the same "selling points" could be easily used by some other framework or two. And that doesn't mean they're untrue or invalid - Symfony2 has those things and has them done good, so sure thing, go ahead, spread the word around about them.
But that doesn't answer the question: "why would I want to use Symfony over X?", as X has the same things done too.
For that, I would really want to read about some stuff unique to S2, be it either some specific features or some of the architectural solutions - I believe those are the things that really differentiate Symfony2 from the others.
There is a real opportunity for sinatra like libs like Silex for php beginners . It embrace a REST-like interface and development good practices yet it is easy to use. I got up and running with Silex in a matter of hours ( i made a quick simple sample app on github : http://bit.ly/SsAjXK ) . and Silex is a bridge to Symfony apps.
So why Symfony instead of X or Y : modularity , huge community , IDE support like Netbeans , DRYness with the bundle system , third party lib integration like Doctrine ... , templates with Twig , great docs , and backed by an awesome company.
I am very much agree with all of You that out there are very good frameworks and also that both SF2 and ZF2 are good frameworks too
Personally, I love Symfony2 because its simplicity and the great power it have
Many thanks to Fabien Potencier and also to the great Symfony Community
stability of code.
These 2.0 and 2.1 releases of Symfony reminds me so much of 1.1 and 1.2, where a lot of developers were excited with new features ( interestingly similar was that they both involved the form framework ), but projects on those minor releases were simply a nightmare to maintain. For developers that have been known for reliability, it's not very acceptable for clients to know that their projects are not built for long term support. Last year, I noticed a sudden surge of client demand for 2.0 development but it has since steadily declined.
In addition to a @Jaime Suez , 2.x still does not have an Askeet/Jobeet reference project that makes
the transition easier for new adapters. Those reference projects just made it extremely easy for any
developer to take someone else's past work and go over the code. It was able to set a very strong standard
on the framework implementation.
"So, besides the buzzwords, what is unique to Symfony? Why would you want to use Symfony instead of X (replace X with ZF, CakePHP, Lithium, Laravel, Slim, Yii, you name it)? That's the question I'm going to answer in this post."
As a developer, none of the mentioned "unique features" to Symfony2 mentioned in this post sells me on using the framework.
This post is more of what Symfony has accomplished, instead of what is unique about it/what makes it better than the rest.
I respect Fabien and what he's done with the framework, but honestly, there is nothing in this post that convinces me to use Symfony over Framework x (ZF, CakePHP, Lithium, Laravel, Slim, Yii etc).
In a post like this, I expect something a bit more technical as to why I should consider using Symfony over any other framework, instead of having only achievements that Symfony accomplished.
I have my personal opinions as to why I would rather use Symfony over any other framework, but I believe every user have personal taste, and would prefer some features of framework x over framework y.
So what I'm trying to say is that this post is nowhere near convincing any user to use Symfony over any other framework, but rather a list of accomplishments that Symfony has achieved.
Every developer have the opportunity to explore various frameworks, and will eventually choose the framework they are most comfortable with, but despite the lack of
convincing this post offer, I would still choose Symfony over any other framework, and that has everything to do with personal experience and absolutely nothing to do with Symfony's achievements over the years.
I would suggest to pick up 5 experiences from 5 users of different levels. One beginner with no experience with Symfony that managed to create a big project, one more advanced user that switched to symfony because it suit his needs, 2 others..., and someone who is VERY experienced, runs a VERY big website, and gets the business done. Symfony is perfection, and people need to know, through experiences. Experiences are the only thing that matter to a framework chooser. So Fabien, within this large community, it wouldn't be hard to find 5 success stories from people that have different knowledge in the framework. They could simply explain why they chose Symfony? Why they are still using it? What they managed to do with it? And in how much time? Long life to symfony.
maybe it could be possible to have a few key frameworks collaborate on such a comparison. maybe each framework writes up something, then everyone compares the write ups to ensure the format is somewhat similar and key differences are highlighted and universally available features dont cloud the message
This brings additional 'trust'... ;)
PSR-0 and namespaces are profoundly important developments to the professional php developer community. Along the same lines, in a few short years, git has completely surpassed svn for team development. Large open source projects are facilitated by software configuration management tools. These tools power the sites that act as hubs. Remember when sourceforge was the center of the opensource universe? Now there is this place called github. People coalesce around the tools and communities that represent the best practices of software development.
As a long time observer of trends in the php community, and someone who worked on large projects written in ZF1 and SF1, I commend both communities for having the self awareness and guts to completely throw away frameworks that were used by a lot of people to do a lot of work. In their own way, both communities have looked to the future rather than the past, and been willing to admit that if php is going to continue to be viable, we needed better quality frameworks, and better ideas.
Symfony2 was the first framework to embrace these changes and build upon them, and get something in a releasable documented form into the hands of developers.
Fabien as the thought leader of the Symfony project, has been faster, more vocal and seemingly quicker to recognize the types of features sophisticated php developers need. This just isn't the case with Zend framework.
I think one reason for this is that here is an advantage to having a company that uses the Symfony tools in its consulting practice. Sensio eats their own dogfood, and has attracted other companies like KnpLabs to do the same.
It's not that there isn't some great stuff in ZF, or that much of it is not well written. There are great developers working on both projects. ZF is a lot larger and more ambitious, or at least it has been in the past. But it has often been overburdened by an academic interest in extreme generalization and decoupling to the detriment of people just trying to get started, who simply wanted someone to tell them or show them how to solve common problems so that they can solve their own.
It's also worth noting that implementing a Dependency Injection framework with a DI Container as Symfony2 did, and being the first to get there IS something worth noting. Implementing a PSR-0 class loader that other projects could use, and getting that out there WAS important, not just to Symfony2, but to the entire php library development community.
Fabien is a diplomat, but I don't have to be. Symfony2 is the best PHP framework in PHP's history. It is a much needed step forward. A lot of people were looking for a project like this to justify their investment in php and facilitate the projects they want to build with the stack.
I'd warrant that a lot of people who discover Symfony2 annotations, fall in love with what they do for you in terms of development, will have a pretty hard time going back to the days of disconnected configuration files. What is available in Doctrine2 and Symfony2 in terms of annotation support is unprecedented for PHP.
Everyone else is a day late to the game at this point, and given the uptake and number of symfony bundles out there, I believe Symfony2's momentum will only continue to increase in velocity. There is a reason that a project like Drupal decides to rebuild themselves on top of the Symfony core. There is a reason why the guy who gave us the GD Library (just admit that you've used it at one time or another) became a Symfony1 (and now 2) user and ecosystem contributor. Everyone who was doing PHP at the time ZF was started, wanted it to become the type of framework that Rails was to Ruby. At last, PHP has a standard bearer -- it just happens to be lead by a french guy, and is called Symfony2.
As you said, Symfony is not a framework but a project, the same thing is true for zend framework, you don't need to use one or anothers MVC implementation, you can use a lot of parts/modules without having to use the library/project as a whole.
All other arguments in favor of symfony are also true for the zend framework, uses php5.3, big community and so on ... So why bother choosing one or another.
The great thing about todays frameworks is that they are PSR compliant, that means you dont need to choose one or another, you can use parts of all of them into your projects. Just create a basic composer.json file. You can choose to use doctrine2 and symfony's doctrine brige, symfony filesystem and for example zend frameworks authentification and validator classes or even add a bunch off unofficial components you found on github.
Composer will download the latest version of your favorite components and create and autoloader for you so that you are ready to go within minutes.
In my view when I go for picking a framework I would consider the following stuff.
1. Will see if how often would I need a extension to be updated.
2. What is the expected level of growth/rate of increase in traffic to the app, which will decided which f/w should be picked up. Have to pick up a f/w which is able to handle the existing load and expected load and beyond possibly nicely.
3. Ease of use change with person to person, which is tightly bound to your coding practices and type of work experience you have, and the very requirement for which you are looking for a smart pick.
4. The fact of having scope of support and maintainance of the f/w comes into focus if you expect considerable growth of your app and which will be there actively updated ever and you put in effort which you never want to migrate to another one if you find the f/w you are using is getting outdated and no chance of getting it updated to time.
5. There is no point in thinking like who did one stuff first but have to consider who the candidates did the stuff. The later will always enjoy the possibility of looking into what flaws or drawbacks are there with the first one. But the challenge to the earlier one will be to make compatible to all the other stuff, design patten, architecture and process model followed till date, as the f/w shouldn't put its user in dark for making it into a better styled one.
6. I would always consider the chance of getting the f/w outdated with the newer versions of coding language being used, will go for picking the one which is less tied to the underlying language so that it may introduce some adhoc work to be done to get the app working again with the updated version of language on the server (say PHP)
many more things will diff developers consider, and same developer may think and choose different f/w different requirement, its the matter of choise which matches the current need and the scope of future expansions.
Now , of course you still need a kernel , a basic way to route , handle requests and load scripts accordingly , and you can make your own. What matters is PHP big players are now talking together to push the community forward , after all we are all coding in the same langage , ie PHP.
PHP need to be where Ruby/Rails or .Net is , a few main frameworks and , around it a ton of good libraries , but also better tools to integrate professional workflow and Agile methods. But PHP must also take advantage of what it is , a very simple hypertext processor that you can easily deploy on a server , write shell script . With the help of big framework like Symfony or Zend , and micro frameworks like Silex we can acheive that goal and make PHP developpers enjoy the coding even more.
I'm a Rails and Grails developer, I like Symfony because it's good, solid, and because it "force" (note the "") developers to use a default stack of technologies; for example, Doctrine integration is very important for my company, and that's because we'll never user Zend. Coming from Rails Active Record and Grails GORM I hope writing Zend_Db stuffs nowadays is simply ridicolous. Obviously I know is possible to integrate in ZF any ORM/DBAL is nedeed, but doin so we are missing the point. If I start a Zend-project with a new developer I'm sure he knows Zend_Db stuffs, I'm sure he don't know Doctrine and how to integrate it in ZF; instead if I start a Symfony-project I'm sure a new recruited developer has knowledge of Doctrine(or Propel). The words are default stack, standard, and best practices, learn from Rails (and Grails), other ways are ridicolous nowadays