Weave Code
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 provides flexible, composable routing for PHP applications, with HTTP/console route types, route matching and assembly, and integration points for Laminas MVC/Mezzio. Includes CI-tested components and configurable route stacks.

View on GitHub
Deep Wiki
Context7

Flexible routing system for HTTP and console applications

Frequently asked questions about Laminas Router
Can I use Laminas Router directly in Laravel without extra packages?
No, Laminas Router isn’t designed for Laravel’s native routing system. It’s built for PSR-7 middleware stacks like Mezzio or Laminas MVC. You’d need a bridge package (e.g., `laminas/laminas-router-glob`) or rewrite routes manually, which isn’t recommended for production.
What Laravel alternatives offer similar routing flexibility?
For Laravel, consider `spatie/laravel-honeypot` (for route-based honeypots), `spatie/laravel-route-tools` (for route caching), or Laravel’s built-in router with `Route::group()` for nested routes. For PSR-7 style, try `php-di/http-router` or `fastroute/fast-route`.
Does Laminas Router support Laravel’s route caching?
No, Laminas Router doesn’t integrate with Laravel’s route caching (`php artisan route:cache`). It’s optimized for dynamic, middleware-driven routing. If you need caching, pair it with a Laravel-compatible package like `spatie/laravel-route-tools` or use Laravel’s native router.
How do I install Laminas Router in a Laravel project?
Run `composer require laminas/laminas-router`, but note this won’t auto-configure Laravel routes. You’d need to manually bind it to Laravel’s service container (e.g., in `AppServiceProvider`) and override the router, which is complex and not officially supported. Test thoroughly in a staging environment first.
Will Laminas Router work with Laravel’s API resources?
Not natively. Laminas Router lacks Laravel’s API resource conventions (e.g., `Route::apiResource()`). You’d need to define routes manually using its segment/literal syntax, which defeats Laravel’s built-in API scaffolding. For APIs, stick to Laravel’s router or use `dingo/api` for advanced needs.
Can I use Laminas Router for console commands in Laravel?
Yes, but with limitations. Laminas Router supports console routes, but Laravel’s Artisan commands use a different dispatch system. You’d need to integrate it via a custom command resolver, which isn’t straightforward. For console routing, Laravel’s native `Route::console()` or `laravel-zero/laravel-zero` are better choices.
Does Laminas Router support regex route matching like Laravel?
Yes, Laminas Router supports regex matching via `Regex` route types, similar to Laravel’s `where()` constraints. However, the syntax differs: Laravel uses `Route::get('/user/{id}', ...)->where('id', '[0-9]+')`, while Laminas uses `Regex('user/{id}', '/^user/([0-9]+)$/')`. Test regex performance in production—Laminas’ regex engine may not be optimized for Laravel’s scale.
Is Laminas Router actively maintained for Laravel compatibility?
No, Laminas Router is maintained for the Laminas ecosystem (PSR-7, Mezzio). Laravel compatibility isn’t a priority. The package’s last major update focused on Laminas 4.x, and breaking changes may occur without Laravel-specific fixes. Check the [Laminas GitHub](https://github.com/laminas/laminas-router) for deprecations.
How do I handle middleware with Laminas Router in Laravel?
Laminas Router integrates with PSR-15 middleware, but Laravel uses its own middleware stack. You’d need to bridge them via a custom `MiddlewareDispatcher` or use `psr/http-message` adapters, which adds complexity. For Laravel, use `Route::middleware()` or packages like `fruitcake/laravel-cors` for middleware-heavy routes.
What’s the performance impact of using Laminas Router in Laravel?
Laminas Router is optimized for Laminas’ lightweight stack, not Laravel’s heavyweight services. Expect slower route matching due to PSR-7 overhead (e.g., request/response objects). Benchmark with `phpbench/phpbench` in staging—if latency exceeds 10ms per request, consider Laravel’s native router or `fastroute/fast-route` for a drop-in replacement.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai