Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laminas Router

Laminas Router Laravel Package

laminas/laminas-router

Laminas Router is a flexible PHP routing component for matching HTTP and console requests to handlers and generating URLs from route definitions. It supports tree routing, route assembly, and integration with laminas-mvc and Mezzio.

View on GitHub
Deep Wiki
Context7

laminas/laminas-router is a flexible routing component for PHP applications, providing a standalone solution for matching HTTP requests to handlers. It supports both literal and segment routes, along with tree-based route aggregation, making it easy to build hierarchical routing structures with optional constraints and defaults.

  • Literal and segment routes with parameter constraints and defaults
  • Route trees for organizing nested, modular routing
  • HTTP method and scheme matching per route
  • Pluggable route plugins for custom matching logic
  • Framework-agnostic, usable standalone or with Mezzio/Laminas MVC
Frequently asked questions about Laminas Router
Can I use laminas/laminas-router in a Laravel application?
Technically yes, but it is not a drop-in Laravel package. laminas/laminas-router is part of the Laminas MVC ecosystem, while Laravel routing is owned by Illuminate\Routing\Router and coupled to middleware priority, route model binding, signed URLs, route:cache, throttling, and CSRF aliases. A viable integration would be an isolated adapter running alongside Laravel's router, which creates two sources of truth for URLs and 404/405 semantics. For most Laravel applications, the native router is the correct choice.
How do I install laminas/laminas-router with Composer?
Run composer require laminas/laminas-router; it is a normal Composer package and does not auto-register a Laravel service provider. You must construct the route tree and invoke match() yourself or through an adapter. Also confirm which request abstraction 3.18.x supports, because the README's laminas-http wording conflicts with the package moving laminas-http to require-dev. If you need PSR-7 requests, expect to add laminas-diactoros or write a converter.
Does laminas-router support Laravel route model binding and route:cache?
No. Route model binding, route:cache, signed URLs, middleware aliasing, and URL generation by route name are Illuminate features, not laminas-router features. An adapter can dispatch matched params into a controller, but it does not recreate Laravel's HTTP kernel contract. Replacing the router means replacing those integrations, so plan for duplicate routing behavior rather than a clean swap.
What route types does laminas-router support?
laminas-router supports literal, segment, regex, wildcard, placeholder, method, hostname, scheme, and child routes, plus route assembly and a config-driven router. Those are real capabilities and its route-tree lookups are credible. Laravel already covers hostname routing with Route::domain(), parameter constraints with Route::pattern(), and hierarchical composition with grouped prefixes. The overlap is high, while Laravel's integration depth is much greater.
Which request abstraction does laminas-router 3.18.x support: laminas-http or PSR-7?
That is the key ambiguity to resolve before estimating any bridge. Release 3.15.0 moved laminas-http to require-dev, yet the README still describes routing against the laminas-http request/response. Confirm the supported contract at 3.18.x; if it is PSR-7, a Laravel adapter must convert Illuminate\Http\Request into a PSR-7 request and map the match result back. If it is laminas-http, the bridge and dependency set are different.
Is laminas-router a good alternative to Laravel's built-in router for performance?
Do not assume a performance win without a measured symptom. Laminas' route tree and b-tree lookups are legitimate, but Laravel compiles routes into a Symfony RouteCollection that already delivers comparable lookup performance. For a typical Laravel route count, middleware, binding, caching, and URL generation matter more than raw match latency. Profile first; if you have not measured a problem, this package adds integration risk without a clear benefit.
What is the maintenance status of laminas-router?
It is stable but caretaker-maintained. Recent releases are dominated by Renovate bot PRs, PHP version floor changes, docblock normalization, and PHPUnit syntax updates from a very small contributor set. Adoption signals are thin: roughly 35 stars and zero dependents, so there is little downstream validation or community troubleshooting. Treat it as a stable component, not a platform to build a Laravel routing layer on.
Will laminas-router's next major release break my integration?
The 3.18.0 notes add soft @final markers signalling final classes in the next major, rename Http\RouteMatch to HttpRouteMatch, introduce HttpRouteInterface, and deprecate Http\RouteInterface. A major release with backward-compatible breaks is signposted, and an adapter written today may target an already deprecated interface. Ask whether the next major has a published timeline before committing engineering time.
How do I test a Laravel integration with laminas-router?
Test the adapter at two levels: unit tests that build the Laminas route tree from config, convert a request, and assert match() params, and integration tests that hit Laravel's kernel to verify 404/405 behavior and controller dispatch. Also test the boundary cases where Laravel and Laminas disagree on route priority or method handling. If you keep Laravel's router as the primary system, test that the two routing sources do not produce conflicting URLs.
What are better alternatives to laminas-router for Laravel?
For Laravel, use the native router with Route::domain(), Route::pattern(), grouped prefixes, middleware, and route:cache; it is the only option with full framework integration. If you need a standalone PSR-7 router outside Laravel, evaluate FastRoute or Symfony Routing instead of pulling in a Laminas MVC component. The BSD-3-Clause license is commercially compatible, but confirm attribution handling in your NOTICE or distribution artifacts. Do not adopt laminas-router just for hostname or scheme routing that Laravel already supports.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator