Skip to content

feat(symfony): add routePriority to control route matching order#8309

Open
soyuka wants to merge 1 commit into
api-platform:mainfrom
soyuka:feat/route-priority
Open

feat(symfony): add routePriority to control route matching order#8309
soyuka wants to merge 1 commit into
api-platform:mainfrom
soyuka:feat/route-priority

Conversation

@soyuka

@soyuka soyuka commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Adds a new nullable ?int $routePriority operation attribute that maps to the third argument of Symfony's RouteCollection::add(string $name, Route $route, int $priority = 0), controlling the URL-matching precedence of the route generated for an operation.

This is distinct from the existing priority attribute, which sorts operations within a resource via Operations::sort(). routePriority instead controls cross-route matching order in the Symfony router, which the per-resource sort does not cover.

Wired through all HTTP operation subclasses (Get, GetCollection, Post, Put, Patch, Delete, NotExposed, McpResource, McpTool) plus the YAML/XML extractors and XSD schema, so it is configurable from every metadata format.

Test plan

  • ApiLoaderTest asserts an operation with routePriority: N registers the route at priority N, and that an operation without it stores no priority.
  • tests/Symfony/Routing green (5/5).
  • PHPStan + php-cs-fixer clean on changed files.

Closes #8135

Expose Symfony RouteCollection::add() third argument via a new nullable
?int $routePriority operation attribute, distinct from the existing
$priority (which sorts operations within a resource).

Wired through all HttpOperation subclasses (Get, GetCollection, Post, Put,
Patch, Delete, NotExposed, McpResource, McpTool) and the YAML/XML
extractors + XSD schema so the attribute is usable from every config format.

Closes api-platform#8135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Symfony API loader do not consider route priority

1 participant