v1.48.0 — Imai: Router Verb Completeness
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
PATCHandOPTIONSare 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 acceptsPATCH,OPTIONSandHEAD
(previously it threwInvalidArgumentExceptionfor anything but GET/POST/PUT/DELETE).PATCHandOPTIONSwere previously
unreachable through the public routing API.- Explicit
OPTIONSroutes take precedence over automatic CORS preflight. Dispatch still answersOPTIONSautomatically (204
Allow) when noOPTIONSroute 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
RoutePrecedenceTestpinning all three precedence tiers, constraint-based fall-through, single-segment parameter matching,
trailing-slash normalization, and method isolation. Corrected a misleading in-code comment inRouter::match()that claimed a
specificity sort the router does not perform.
Upgrade: composer update glueful/framework — no action required.