Skip to content

v1.48.0 — Imai: Router Verb Completeness

Choose a tag to compare

@MichaelSowah MichaelSowah released this 31 May 18:16
· 164 commits to main since this release
5bf42c4

Theme: Router Verb Completeness. PATCH and OPTIONS become first-class routing verbs (they were previously unreachable
through the public API), explicit OPTIONS routes win over the automatic CORS preflight responder, and the route-precedence model
is documented and pinned with tests. Purely additive — no breaking changes, no new env vars, no migrations.

Added

  • PATCH and OPTIONS are now first-class HTTP verbs in the router. New $router->patch() / $router->options() shortcuts
    and #[Patch] / #[Options] attributes, and the #[Route(methods: [...])] array form now accepts PATCH, OPTIONS and HEAD
    (previously it threw InvalidArgumentException for anything but GET/POST/PUT/DELETE). PATCH and OPTIONS were previously
    unreachable through the public routing API.
  • Explicit OPTIONS routes take precedence over automatic CORS preflight. Dispatch still answers OPTIONS automatically (204
  • Allow) when no OPTIONS route is registered for the path, but a route registered via $router->options(...) / #[Options]
    now runs its own handler instead of being shadowed.

Documentation

  • Documented the route-cache closure limitation (closure handlers are never cached; the router skips/discards the cache for
    them and resolves them live) and the expanded HTTP-method surface.
  • Documented the route-precedence model (static beats dynamic; literal first segment beats a parameter first segment; within a
    first-segment group, registration order wins — register the more specific overlapping pattern first).

Tests

  • Added RoutePrecedenceTest pinning all three precedence tiers, constraint-based fall-through, single-segment parameter matching,
    trailing-slash normalization, and method isolation. Corrected a misleading in-code comment in Router::match() that claimed a
    specificity sort the router does not perform.

Upgrade: composer update glueful/framework — no action required.