Skip to content

[Routing] configure trailing slash on imported routes #12141

Closed
@Tobion

Description

@Tobion

There is currently a known limitation when using route imports that makes it impossible to to have a root route / be imported under a prefix without a trailing slash. See #4322 and silexphp/Silex#149

I propose to solve this problem in a generic way by offering an option when importing routes to remove or add trailing slashes (which defaults to null, meaning not modifying anything):

AcmeBusinessBundle_client:
    resource: "@AcmeBusinessBundle/Resources/config/routing/client.yml"
    prefix:   /clients
    trailing_slashes: true|false|null

This way, the users can unify the path on import the way they want.

So for example

acme_business_client_list:
    path:  /
    defaults: { _controller: AcmeBusinessBundle:Client:list }

imported with trailing_slashes: false under prefix: /clients will result in path /clients instead of /clients/.

The other case with trailing_slashes: true is helpful when you import third party routes without trailing slash but you decided that you app should use training slashes everywhere consistently.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions