Refactor language URL routing to use explicit @lang special route tokens instead of positional segment detection
まだ誰も着手していません。
評価
調査の方向性
まず src/Router/PatternCompiler.php、src/Router/MatchedRoute.php、src/Http/Traits/Request/Route.php、src/Lang/Factories/LangFactory.php を読み、次に既存のルーティングテストを確認してください。ルートトークンと言語解決が現在どのように機能しているかを追跡してください。@lang ルートがサポート対象の言語にマッチし、言語を通常のパラメータではなくルートコンテキストとして保持し、対応するテストと、必要に応じて更新されたテンプレートまたは例が用意されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Refactor Quantum language URL routing so routes can explicitly declare language segments using the special route token:
@lang
instead of relying on positional URL segment detection through config such as lang.url_segment.
Why
Current language URL handling is implicit and positional.
Today, language detection relies on config-driven segment index logic, for example:
lang.url_segment
and the framework then tries to detect the language by reading a configured request segment position, with additional prefix-aware adjustment logic.
That works, but it has several weaknesses:
- route structure does not explicitly show where language lives
- language handling depends on URL segment position math
- routes are harder to reason about when combined with prefixes or other special segments
- the model does not align with the new special route token direction
With special route token support in place, language routing should become explicit in the route pattern itself.
Goal
Allow routes to explicitly declare the language segment using:
@lang
so the router can treat language as a framework-owned route context rather than a positional URL convention.
Proposed Direction
Routes that are language-aware should explicitly include:
@lang
Examples:
$route->get('@lang/posts', 'PostController', 'posts');
$route->get('@lang/post/[uuid=:any]', 'PostController', 'post');
This should allow URLs such as:
/en/posts/es/posts
or, when module prefix is present:
/web/en/posts/api/en/posts
depending on module prefix configuration.
Config Direction
Language config should continue to define language behavior such as:
- whether language is enabled
- supported languages
- default language
But routed language placement should no longer depend on positional config like:
lang.url_segment
The route itself should explicitly declare where language lives.
Important behavior
The resolved language should be:
- matched through the
@langtoken - validated against configured supported languages
- made available to framework internals as language route context
- kept distinct from ordinary controller action parameters by default
Migration Direction
This feature should replace routed language URL detection based on positional segment config for routes that adopt @lang.
Backward compatibility strategy can be decided during implementation, but the intended direction is for explicit routed language segments to become the preferred and cleaner model.
Acceptance Criteria
- routes can explicitly declare language position using
@lang - matched
@langvalues are validated against configured supported languages - language route context is resolved through
@langrather than positional URL segment detection for token-based routes - routed language values do not become ordinary positional controller action parameters by default
- tests cover
@langroute matching and language resolution behavior - templates and examples can be updated to use
@langwhere appropriate
Notes
Relevant code:
src/Lang/Factories/LangFactory.phpsrc/Router/PatternCompiler.phpsrc/Router/MatchedRoute.phpsrc/Http/Traits/Request/Route.php- module route templates currently using language-prefixed route patterns
This ticket depends on:
- 主要言語
- PHP
- スター
- 36
- フォーク
- 22
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quantum-php/framework のほかの issue
-
routing testing
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
quantum-php/framework#547 ·
-
view
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
quantum-php/framework#542 ·
-
enhancement http
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
quantum-php/framework#565 · コメント 1 件 ·
-
components view
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
quantum-php/framework#551 ·
-
Add explicit @version special route token support for API major versioning within a single moduleオープンrouting
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
quantum-php/framework#550 ·
quantum-php/framework の issue をすべて見る
似ている issue
-
[Sync EN] Fix session read handler docs: false reports a failure, not a missing session (#5902)オープンsync-en
難易度 2/5 1〜2日 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信
-
feature-request needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws/aws-sdk-php#3365 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
-
bug status: unverified
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
woocommerce/google-listings-and-ads#3884 ·
メンテナーはふだん 1 日以内に返信