Skip to content

Document variable path segment routes#471

Open
samdark wants to merge 1 commit into
masterfrom
docs-variable-url-parameters
Open

Document variable path segment routes#471
samdark wants to merge 1 commit into
masterfrom
docs-variable-url-parameters

Conversation

@samdark
Copy link
Copy Markdown
Member

@samdark samdark commented May 30, 2026

Summary

  • add routing guide examples for bounded variable-depth routes with nested optional parts
  • document how arbitrary-depth regex route arguments behave
  • warn that generated catch-all route arguments encode slashes as %2F, so optional parts are better for generated hierarchical URLs

Verification

  • Used a fresh yiisoft/app template created with composer create-project yiisoft/app /tmp/yii-docs-upload-app --no-interaction
  • Added verify-variable-url-parameters.php to exercise Yii Router matching and URL generation
  • Ran php -l verify-variable-url-parameters.php
  • Ran php verify-variable-url-parameters.php; verified:
    • /docs
    • /docs/guide
    • /docs/guide/routing
    • catch-all generation gives /files/2026%2Freport.pdf
    • catch-all matching captures path => 2026/report.pdf
  • Ran vendor/bin/phpstan analyse verify-variable-url-parameters.php --level=max --no-progress
  • Ran vendor/bin/psalm --no-cache --output-format=console verify-variable-url-parameters.php
  • Ran npx markdown-link-check src/guide/runtime/routing.md
  • Ran npm run build

Copilot AI review requested due to automatic review settings May 30, 2026 10:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the routing guide with examples for variable-depth URL paths, covering both bounded optional route segments and catch-all regex parameters.

Changes:

  • Adds a new routing subsection for variable numbers of path segments.
  • Documents nested optional parts for predictable matching and URL generation.
  • Explains catch-all regex route behavior and %2F encoding during URL generation.


Optional parts are only supported in a trailing position, not in the middle of a route.

### Variable number of path segments
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.

2 participants