juanitourquiza juanitourquiza - 1 month ago 14
YAML Question

Annotations or yaml - Symfony3

For routes that are best used
In the good practices recommend

Which is better and why?


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