Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Accessing route options #11171

Copy link
Copy link
Closed
Closed
Copy link
@sprain

Description

@sprain
Issue body actions

Routes can have additional options, like this:

some_route:
    pattern:  /my/nice/pattern
    defaults: { _controller: MyBundle:MyController:MyAction }
    options:
      foo: 'bar'

To access routing options in a controller you need to call $this->get('router')->getRouteCollection()->get($routeName)->getOptions(). However, getRouteCollection() is a very expensive call and destroys all route caching advantages, even in prod env.

It is not clear for a developer that routing options are not meant to be used in a controller. The only place this is mentioned seems to be in #4436.

There should be either 1) a more efficient way to access route options or 2) a clearer best practice guide on what route options are meant to be used for and what the alternatives are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.