Skip to content

YAML routing host overrides annotations #54211

@Bilge

Description

@Bilge

Symfony version(s) affected

6.4.3

Description

Looking for a way to set the default hostname for routes, this SO answer should be correct, but as a comment notes, setting the host name in YAML clobbers any and all annotations parsed thereafter.

That is, YAML that defines an annotations/attributes resource must be parsed before the attributes:

# config/routes/routes.yaml

controllers:
  resource:
    path: ../../src
    namespace: Foo\Bar
  type: attribute
  host: example.com

So it follows that logically that which is parsed later should override that which is declared earlier.

#[Route(host: 'example.org')]
final class Foo extends AbstractController {}

Yet it does not: setting the host in YAML clobbers all Route() attributes. Thus it appears impossible to set a default host since we are not in control of this parse order.

How to reproduce

See above.

Possible Solution

No response

Additional Context

No response

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