mhvvzmak1 mhvvzmak1 - 5 months ago 40
PHP Question

Symfony routing - annotations

I recently looked into the Symfony framework as I'd like to use it for some projects, however noticed that the routing is extremely awkward to use due to something called "annotations" which are basically comments above each controller method.

Is it possible to create a routes.php file and use that to overwrite the routing and completely disable these annotations? As I would like all routes in one file so it is much more flexible and maintainable.

1ed 1ed
Answer

You can use xml, yaml, php or annotation for route definitions. You just need to change this line in app/config/config.yml from

framework:
    router:
        resource: "%kernel.root_dir%/config/routing.yml"

to

framework:
    router:
        resource: "%kernel.root_dir%/config/routing.php"

create app/config/routing.php and remove app/config/routing.yml