Repository navigation
After more than a decade of shipping on 0.x, Routes finally gets an official 1.0. Same code as 1.0.0-rc.2, which soaked for over two weeks without a blocker.
Upgrading from 0.x? There are breaking changes below, and the README has a full Upgrading to 1.x guide.
Breaking changes
- PHP 8.2+ required.
Routesis now a singleton — useRoutes::get_instance()instead ofnew Routes().- The
$upstatement_routesglobal is gone — useRoutes::get_instance()->match_current_request(). - No auto-instantiation on include — the singleton is created lazily on your first
Routes::map()call. - Base path is now derived from your site URL. If WordPress lives in a subdirectory and your routes included that prefix, drop it:
Routes::map('blog/my-page', …)becomesRoutes::map('my-page', …).
New
Routes::add_match_types()registers custom AltoRouter match types:Routes::add_match_types(['hex' => '[0-9A-Fa-f]+']); Routes::map('color/[hex:color]', fn ($params) => /* $params['color'] is hex */);
- Base path support for subdirectory installs.
Fixed
- WordPress canonical redirects no longer hijack matched routes (#53, fixes #13).
- Route parameters accept dots, so
download/:versionmatches1.5.1(#45). - Slug parameters match any non-slash character, fixing a Unicode regression.
Under the hood: Rector and ECS in CI, plus a test matrix across PHP 8.2–8.5 and WordPress 6.3 through trunk.
Full changelog: 0.10.0...1.0.0