Skip to content

1.0.0

Latest

Choose a tag to compare

@jarednova jarednova released this 28 Jul 13:36
eed7560

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.
  • Routes is now a singleton — use Routes::get_instance() instead of new Routes().
  • The $upstatement_routes global is gone — use Routes::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', …) becomes Routes::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/:version matches 1.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