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
Simple Router

Simple Router Laravel Package

pecee/simple-router

A fast, lightweight PHP router with a simple, expressive API. Supports route groups, middleware, custom regex patterns, named routes and reverse routing, plus optional parameter binding and subdomain routing. Works with or without a framework.

View on GitHub
Deep Wiki
Context7

Pecee Simple Router is a fast, lightweight PHP routing library that makes it easy to map URLs to controllers and closures. It supports RESTful routing, route groups, and middleware, giving you clean, maintainable code without heavy dependencies. Perfect for small to medium projects that need flexible routing with minimal setup.

  • Named routes and URL generation
  • Route groups with prefixes and middleware
  • Optional parameters and regex constraints
  • RESTful HTTP method support
  • Middleware support for request filtering
Frequently asked questions about Simple Router
Is pecee/simple-router a drop-in replacement for Laravel's router?
No. Pecee Simple Router mimics Laravel's routing syntax, but it is a standalone dispatcher without Laravel's container, middleware pipeline, route model binding, signed URLs, authorization gates, rate limiting, or route:cache. Substituting it into a Laravel app means rebuilding that glue and losing cached-route performance. For Laravel applications, the native router is almost always the better choice.
How do I install pecee/simple-router with Composer?
Install it with composer require pecee/simple-router; it is a Composer-only package with no PHP extensions or external services required. You will still need to choose a PSR-7 implementation and PSR-17 factories if you use its PSR-7/PSR-15 integration, for example nyholm/psr7 or guzzlehttp/psr7. Then wire the router into a front controller or your application's dispatch layer.
Does pecee/simple-router support Laravel 10, 11, or 12?
There is no Laravel version constraint because pecee/simple-router is not a Laravel package. It does not register service providers, integrate with Laravel's HTTP kernel, or follow Laravel's release cadence. Its compatibility target is PHP and PSR HTTP interfaces, not a specific Laravel version. If you need Laravel 10, 11, or 12 routing, use Laravel's built-in router.
Can I use pecee/simple-router inside an existing Laravel application?
Technically you can, but it is not recommended. Running two routers in the same request lifecycle creates ambiguous 404/405 semantics and duplicated middleware, and you lose Laravel's route model binding, gates, signed URLs, and route caching. Pecee is a better fit for legacy or procedural PHP apps, small services, API gateways, and CLI or queue workers that need URL matching without a full framework.
Do I need a PSR-7 implementation to use pecee/simple-router?
Pecee Simple Router is PSR-7, PSR-15, and PSR-17 aware, and for that style of integration you must choose and own a PSR-7 implementation plus PSR-17 factories. Common choices are nyholm/psr7 and guzzlehttp/psr7. The package does not pick that dependency for you, so confirm it does not conflict with your existing HTTP client stack. The core router is lightweight, but the PSR integration is an architectural choice your team owns.
How does middleware work in pecee/simple-router compared with Laravel?
Pecee uses PSR-15 middleware with the process() convention, while Laravel middleware uses handle() and is resolved through the container. You need to reconcile middleware ordering conventions and adapt handlers through your dependency injection container. PSR-15 middleware composes cleanly in standalone services, but it is not a drop-in match for Laravel's middleware pipeline.
What Laravel-style routing features does pecee/simple-router support?
It supports RESTful routes, route groups, prefixes, named routes, parameterized URLs with optional regex constraints, subdomain routing, resource routing, and middleware. The API is deliberately inspired by Laravel, so developers trained on Laravel can become productive quickly. It does not provide Laravel's container integration, route model binding, or route caching.
Is pecee/simple-router still maintained and safe for production?
The project has a single maintainer and the last tagged release was December 2023, so the dominant risk is lifecycle and bus factor rather than code quality. PHP 8.3 and 8.4 compatibility is unverified for the current tag, and a future major version could raise the PHP floor or shift PSR expectations again. The security surface is small but real, covering parameter regex handling, URL generation and encoding, the optional CSRF helper, and subdomain trust behind proxies. Pin the version, smoke-test it on your target PHP runtime, and have a fork, vendor, or replace plan.
Does pecee/simple-router support route caching like Laravel's route:cache?
No. Pecee Simple Router does not provide Laravel's route:cache equivalent, so every request pays the route registration and matching cost. For low-to-moderate traffic that is usually fine, but you should quantify your routing hot path as routes multiplied by requests per second before committing. If cached routing is a hard requirement, Laravel's native router or a framework with route caching is a better fit.
How do I test routes built with pecee/simple-router?
Because the router is a standalone dispatch layer, you can test it by constructing the router, registering routes, and dispatching simulated PSR-7 requests in your test suite. Assert on the response status, headers, body, and the resolved route or named route. You will need to provide your own test harness for container resolution and middleware, since there is no Laravel-style testing integration. Keep integration tests around your front controller and exception handler adapter.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console