Download the PHP package bit55/litero without Composer
On this page you can find all versions of the php package bit55/litero. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package litero
Short Description Extra light router and dispatcher for small web applications.
License BSD-3-Clause
Homepage https://github.com/bit55/litero
Informations about the package litero
Litero
Extra light router and dispatcher for small web applications. Small footprint and no overhead.
Router class in this package maps HTTP-requests by URL pattern to callbacks.
Note: It's component not support PSR-7 HTTP Message Interface out of the box.
Installing
Create project based on Litero in current directory:
And add your application code to autoloading section in composer.json
.
Or include Litero in your existing project:
Or download this repository and include file Router.php
in your project.
Your webserver must point to the index.php file for any URI entered. See .htaccess
for Apache and example.nginx.conf
for Nginx configuration example.
Usage
Create Instance of Router class.
Add routing rules. Routes may contents exact or wildcard rules.
Wildcards example:
/page/:seg
- any characters in one segment like/page/qwerty
or/page/123
;/page/:num
- digits only like/page/123
;/page/:any
- any characters like/page/qwerty
or/page/qwerty/123
;
Route handler may be any callable (function name, closure) or string with controller class name and action method. Router instantiate controller and execute action method automatically.
Wildcard parameters will be passed as function params in handler.
Note if you using Composer, add your controller classes to autoloading.
Add single rule with Closure handler:
Or add array of routes.
Start route processing.
Usage example code see in index.php
file.