Download the PHP package stefanobalocco/damnsmallrouter without Composer
On this page you can find all versions of the php package stefanobalocco/damnsmallrouter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download stefanobalocco/damnsmallrouter
More information about stefanobalocco/damnsmallrouter
Files in stefanobalocco/damnsmallrouter
Download stefanobalocco/damnsmallrouter
More information about stefanobalocco/damnsmallrouter
Files in stefanobalocco/damnsmallrouter
Vendor stefanobalocco
Package damnsmallrouter
Short Description A really simple and small pathinfo php router
License BSD-3-Clause
Homepage https://github.com/StefanoBalocco/DamnSmallRouter
Package damnsmallrouter
Short Description A really simple and small pathinfo php router
License BSD-3-Clause
Homepage https://github.com/StefanoBalocco/DamnSmallRouter
Please rate this library. Is it a good library?
Informations about the package damnsmallrouter
DamnSmallRouter
A really simple and small pathinfo php router
Installation
Install via Composer:
Or add to composer.json:
Run composer install or composer update.
Basic Usage
Initialization
Adding Routes
Error Handling
Default error routes set HTTP response codes and return null. Customize them:
Router Execution
Key Features
- Pattern matching with placeholder support
- Support for multiple HTTP methods
- Customizable error handling with automatic status codes
- Automatic HEAD request handling (converted to GET)
Available Placeholders
#09#: Numbers (\d+)#AZ#: Letters ([a-zA-Z]+)#AZ09#: Alphanumeric characters ([\w]+)
Methods
AddRoute($route, $callback, $variables = [], $method = 'GET', $available = null)
Adds a new route with:
$route: URL pattern with placeholders$callback: Function to execute (receives$variablesfirst, then pattern matches)$variables: Additional variables passed as first parameters to callback$method: HTTP method (GET, POST, PUT, DELETE, etc.)$available: Boolean condition for route availability
RouteAvailable($method = 'GET', $withoutConditions = false)
Checks if a route is available for the current path.
$method: HTTP method to check$withoutConditions: If true, ignores the$availableparameter of routes
Route()
Executes routing for the current request and returns the callback result.
Error Route Methods
AddRoute403($callback, $variables = []): Sets handler for forbidden accessAddRoute404($callback, $variables = []): Sets handler for not foundAddRoute405($callback, $variables = []): Sets handler for method not allowedAddRoute500($callback, $variables = []): Sets handler for internal server errors
All versions of damnsmallrouter with dependencies
PHP Build Version
Package Version
No informations.
The package stefanobalocco/damnsmallrouter contains the following files
Loading the files please wait ...