Skip to content

flex loading files in routes and the route definition without prefix wins over the route definition with a prefix. #9608

Closed
@mackou

Description

@mackou

Hello :
As you can see in this issue : symfony/symfony#26949
It seems that all routing files in config/routes are loaded automatically and it will ignore the prefix.
So you should group routing files by prefix in different folders :

This is working

app_security:
   resource: 'security/security.yaml'
   prefix: /security

image

This is not working

app_security:
   resource: 'security.yaml'
   prefix: /security

image


Quoting @stof :

Well, the Flex kernel is indeed loading all files in routes itself. and this means that the loading of the file done in the kernel might happen after the loading of the file done by your own file (which is likely here, as security.yml comes after routes.yml and so the route definition without prefix wins over the route definition with a prefix.

If you want to split the routes into separate files loaded with a prefix, putting them in a subfolder is indeed a solution.

I suggest adding a warning in the doc about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions