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 for PSR-7 applications

Frequently asked questions about Laminas Router
Can I use laminas/laminas-router as a drop-in replacement for Laravel’s native router?
No, it requires adaptation due to architectural differences. You’ll need to wrap Laminas Router behind a facade or decorator pattern to integrate with Laravel’s `RouteServiceProvider`, middleware pipeline, and `Illuminate/Routing` contracts. Start with a proof-of-concept for 1–2 routes to validate compatibility.
How does Laminas Router’s performance compare to Laravel’s default router for large-scale apps?
Laminas Router uses B-tree lookups for O(log n) route resolution, which outperforms Laravel’s default router for >10K routes. Benchmark with tools like `ab` or Laravel Debugbar to compare latency under load, especially for RESTful APIs or high-traffic endpoints.
Will third-party Laravel packages (e.g., spatie/laravel-permission) work with laminas/laminas-router?
Most packages rely on Laravel’s native routing contracts (e.g., `RouteCollection`, `Route` objects). You’ll need to ensure Laminas’ `RouteMatch` objects are compatible with middleware binding and route resolution. Test critical packages early in your migration path.
Does laminas/laminas-router support Laravel’s route caching (`php artisan route:cache`)?
No, out-of-the-box. You’d need to extend Laravel’s `RouteCacher` to serialize Laminas Router’s internal tree structure. Alternatively, disable caching or use a custom solution to leverage the B-tree’s optimized performance without Laravel’s caching layer.
How do I integrate Laminas Router with Laravel’s middleware system?
Use Laminas’ `RouteMatch` objects to bind middleware via Laravel’s `app()->middleware()` or `Route::middleware()`. Create a wrapper facade to translate Laminas’ middleware binding syntax (e.g., `->addMiddleware()`) into Laravel’s `->middleware()` format.
What’s the migration path from Laravel’s router to laminas/laminas-router?
Phase 1: Replace 1–2 routes (e.g., `/api/users`) with Laminas equivalents, validating `RouteMatch` integration. Phase 2: Extend `Illuminate/Routing/Router` to delegate to Laminas Router. Phase 3: Update `RouteServiceProvider` and test third-party packages for compatibility.
Does laminas/laminas-router support Laravel’s named routes (e.g., `route('profile')`)?
No, named routes require custom logic. Map Laminas’ `RouteMatch` objects to Laravel’s `RouteCollection` manually or build a helper function to generate named route URLs dynamically. This is a common gap in non-native integrations.
How does Laminas Router handle console/CLI routing for Laravel Artisan commands?
Laminas Router supports CLI routes via `ConsoleRoute` and `ConsoleRouteStack`, which can replace Laravel’s basic Artisan command routing. However, complex command logic (e.g., argument parsing) may still require Laravel’s `Artisan` facade or middleware wrappers.
What PHP versions and Laravel releases does laminas/laminas-router support?
Laminas Router drops PHP 8.1 support in v3.16.0, aligning with Laravel’s LTS (PHP 8.2+). For Laravel 10/11, ensure you’re using a compatible Laminas Router version (check the [upgrading guide](https://docs.laminas.dev/laminas-router/upgrading/)). Test edge cases like PHP 8.3 features.
Are there alternatives to laminas/laminas-router for Laravel with better native support?
For Laravel-native solutions, consider `spatie/laravel-routing` (for advanced patterns) or stick with `Illuminate/Routing`. If you need PSR-7 compatibility, `fastroute/fast-route` is lighter but lacks Laminas’ hierarchical routing. Weigh tradeoffs like performance vs. ecosystem lock-in.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky