juanitourquiza juanitourquiza - 10 days ago 6
YAML Question

Annotations or yaml - Symfony3

For routes that are best used
In the good practices recommend
https://librosweb.es/libro/buenas_practicas_symfony/capitulo_1.html

Which is better and why?

Answer

From the Official Doc, in the chapter about Symfony Best Practices regarding controller suggest as best practice to use annotations:

Best Practice

Make your controller extend the FrameworkBundle base controller and use annotations to configure routing, caching and security whenever possible.

The main motivation about this is for readability and simplify the configuration:

In addition, using annotations for routing, caching and security simplifies configuration. You don't need to browse tens of files created with different formats (YAML, XML, PHP): all the configuration is just where you need it and it only uses one format.

No impact about performace (generally all this stuff will be cached and don't depends about the format you choice)

Hope this helps

Comments