Introducing the Official Symfony Best Practices
October 9, 2014 • Published by Javier Eguiluz
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.
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.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
BTW, it writes we should use parameters.dist.yml but the default is to use parameters.yml.dist.
Meanwhile, you can report new errors and typos here: https://github.com/symfony/symfony-docs/issues/4321
$ 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 2.6@dev installation.
@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: https://github.com/sensiolabs/SensioGeneratorBundle/pull/299
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*)
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
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....
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.
However one issue that I found in the book is that it says
"BEST PRACTICE
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
https://github.com/symfony/symfony/issues
BEST regards Oskar
"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".
Thanks