Symfony 6 Certification New exam with updated questions 100% online Show your expertise

Introducing the Official Symfony Best Practices

Fabien Potencier, the leader of the Symfony project, introduced today a new initiative called The Official Symfony Best Practices. During his Symfony Live New York keynote, Fabien briefly described the reason for unveiling this initiative:

Since the publication of Symfony 2.0, the Symfony Community has created an unofficial set of recommendations for developing Symfony2 applications. Unfortunately, a lot of these recommendations are unneeded for web applications. Much of the time, they unnecessarily overcomplicate things and don't follow the original pragmatic philosophy of Symfony.

Fabien, alongside Ryan Weaver and Javier Eguiluz, has compiled 31 of these best practices in a handbook that will be published for free in the coming days at

We know that old habits die hard and some of you will be shocked by some of these best-practices. But by following these, you'll be able to develop apps faster, with less complexity and with the same or even higher quality.

In any case, keep in mind that these are optional recommendations that you and your team may or may not follow to develop Symfony applications. If you want to continue using your own best-practices and methodologies, you can of course do it. Symfony is flexible enough to adapt to your needs. That will never change.

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


This is the most expected docs as for me. Thank you!
This is the most expected docs as for me. Thank you!
Great! So we'll finally get an official best practice on the 'controllers as service' discussion ;-)
Thanks! This book will help teams to work better ;)
Excellent news Javier, this is something that will be very useful for both new and seasoned Symfony developers.
Great news!
Thanks, but what's with the wait?
@Alex, the wait is needed to allow us for the last minute tweaks. We need to test everything well. Thanks for your patience!
That would be great. Big thanks!
is there a french version ?
Thnx for nice news! So we'll finally get an official best practice on the 'controllers as service' discussion +1 )
Great initiative! There will be no controllers as services :)
Really excited for this! Thanks for the effort Javier, Ryan and Fabien :)
I'm logged in with SensioLabsConnect but link is still not available.
Can't download too..
Yup, link not working, shows Login with SensioLabConnect even after you logged in.
wait for the link ;)
Same here.. Can't download.
Same problem. After login I can't download.
Can not download also, see same button about registration
Same here, can't download.
Same here, hoping it will be fixed soon..
Same here :(
Link is working!!!
Great work!
BTW, it writes we should use parameters.dist.yml but the default is to use parameters.yml.dist.
Really enjoying the read, noticed a typo on page 24 $postSlug but in the array you use $slug
Thank you all for reporting these errors and typos. We've fixed all of them and we'll publish a new version of the document very soon.

Meanwhile, you can report new errors and typos here:
This is really great and nice of you to share it to the community. Very useful. Thank you.
I don't know if it is my PDF reader but copy & paste on text blocks will always result in new lines per word. Maybe this can be changed to make it easier to copy content e.g. for my private wiki.
A couple of issues:

$ php app/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction
This command does not work. It throws an error saying that bundles should be prefixed(like Acme\AppBundle or so).

If you move templates to the app/Resources/views and the delete your bundle's views directory, you get an Twig_Loader error.

I've tried this on a [email protected] installation.
Other than that - perfect! Very useful!
@webDEVILopers we're sorry about the PDF issues. If you prefer a text format, the contents of the book have just been committed to the documentation repository:

@Vladislav, you are right about the error when generating bundles without a vendor. There is a PR that fixes this and that it will be merged soon:

Regarding the Twig error, refactoring an application is always going to introduce errors. What you should check is that templates have been moved to the app/Resources/views/, that all template references have been updated (in controllers and in include(), extends and embed Twig tags) and then, make sure to clear the cache (probably by executing: rm -fr app/cache*)
Maybe, I didn't explain correcly :) Deleting the "views" directory from a bundle throws the error, not the refactoring itself. I suppose, the bundle expects the "views" directory to be there.

It's easy to reproduce this. Rename or remove the "views" directory of a bundle and you'll get:

Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'The "/Users/vladislav/Sites/sfplayground/src/AppBundle/Resources/views" directory does not exist.' in /Users/vladislav/Sites/weemss/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 93
Clearing the dev cache fixed that. Sorry. My bad :)
Excellent initiative!

I think that Symfony3 is going to encourage developers to adopt more of interoperability each others while Symfony2 wished to bring too much freedom (for noble causes).

It's very useful for third-party bundles and submitted experimental bundles.

I shall just like bringing another agreement: the usage of [' foo ', 'bar'] instead of the array(' foo ', ' bar') to oblige to use Symfony on servers where php is already very up to date for better performance to desmontrate the powerful of Symfony websites where PHP east the PHP5.5 and the not-too-much-verbose of source code....
Can't wait to discover it.
Once you start understanding the framework, you realize how many solutions it offers for the same problem to resolve, how many different techniques you can use and how many different "things" you can set in motion for the same purpose.

Answering the same solutions the same way can improve understanding and performance in applications made by other people. Having common basics, all of them being oriented towards the same direction, could really help getting into new projects while still being walking on a ground where you can see landmarks and not feel lost.

Thanks to the team.
I have an 80000 lines of code Symfony 2.5 project, that was separated in 6 bundles(non-reusable). Each bundle depended on at least one other bundle. I decided to refactor the project according to the Best Practices. It took me about 6-8 hours. The results are wonderful - better structure, shorter names(services, templates, namespaces etc.), a small performance improvement. I highly recommend every Symfony developer read the book. It's worth it!
Probably the most awaited part of documentation ever. Thanks to all contributors.
This was the missing piece of the documentation ! I am so happy that pragmatism is taking back center stage.
... so thank you Fabien for reminding all of us about the original pragmatic philosophy of Symfony ! That's what has brought me to Symfony 8 years ago.
This book is awesome, and clarified some things for me.
However one issue that I found in the book is that it says

Don't use the form() or form_start() functions to render the starting and ending
form tags."

However in the example right above it you use {{ form_enctype(form) }} which according to the documentation is deprecated and is to be removed in 3.0 and recommended to use form_start instead.

Well which is it? I really think form_start is the better choice, because one other issue by doing it manually, is you have to add the name of the form manually. I really think form_start is a much better option. It says that it doesn't provide clarity... not sure about that seems pretty clear to me?

Can you provide some insight please? Thanks
Kris, that seems a small issue indeed, can you create an issue on github?
Is it possible to generate it as epub?

BEST regards Oskar
In chapter 1 of the Book:
"In addition to this guide, you'll find a sample application developed with all these best practices in mind.
Please refer to the last chapter of this guide to find more details about this application and the instructions to install it."

Where can I find this sample application. I can't see nothing about it in the last chapter "Tests".


Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.