Skip to content

[P3] Model host placeholders as route parameters and clarify URL generation #4

Closed

Description

@42dknp

Problem

Symfony route matching returns both path placeholders and host placeholders as application route parameters. SymfonyRouter intentionally keeps every non-internal matcher value, so a route such as {tenant}.api.example.test/reports/{reportId} currently produces:

$match->pathParameters === [
    "reportId" => "42",
    "tenant" => "acme",
];

Both values are then available to request hydration and override query/body values. This is useful behavior, but the public name pathParameters incorrectly implies that every value originates in the URI path.

URL generation has a related intentional invariant: Router::generate() returns an origin-less reference such as /reports/42; scheme and host are removed even for host-constrained routes.

Proposed direction

Before a stable release, model these values as route parameters rather than path parameters. Prefer renaming the public property to routeParameters; if compatibility must be preserved, provide a documented migration or deprecation path.

Acceptance criteria

  • Host and path placeholders remain hydratable route parameters.
  • The public model no longer mislabels host-derived values as path-only values.
  • Tests cover a route with both a host placeholder and path placeholder.
  • Hydration precedence for route parameters over query and body is documented.
  • The origin-less return contract of Router::generate() is documented and tested for host- and scheme-constrained routes.

Activity

  1. added a commit that references this issue on Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions