Download the PHP package solophp/router without Composer
On this page you can find all versions of the php package solophp/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download solophp/router
More information about solophp/router
Files in solophp/router
Package router
Short Description A lightweight and flexible PHP router with middleware support, route groups, and named routes
License MIT
Informations about the package router
Solo Router
A lightweight and flexible PHP router with middleware support, route groups, and named routes.
Note: This is version 2.0.0 with breaking changes. If you're upgrading from version 1.x, please check the Migration Guide for detailed instructions.
Requirements
- PHP 8.1 or higher
- Composer
Installation
You can install the package via composer:
Basic Usage
Features
HTTP Methods Support
- GET
- POST
- PUT
- PATCH
- DELETE
Route Parameters
Invokable Controllers
Router supports invokable controllers that implement __invoke
method:
Named Routes
Route Groups
Route groups allow you to share route attributes like prefixes and middleware:
Page Attributes
Routes can have an optional page attribute for identifying specific pages or sections:
Middleware Support
Route Information
When a route is matched, it returns an array containing:
method
- HTTP methodgroup
- Route group prefixhandler
- Route handler (callable, controller array or invokable class name)args
- Route parametersmiddleware
- Optional Array of middlewarepage
- Optional page identifier
Error Handling
The router throws InvalidArgumentException
in the following cases:
- When adding a route with an unsupported HTTP method
- When trying to name a route before adding any routes
- When trying to use a route name that already exists
Testing
License
This package is open-sourced software licensed under the MIT license.