jlanger / router
Router
v3.2.1
2020-10-19 09:25 UTC
Requires
- php: >=7.4
- ext-json: *
- jlanger/di: ^2
Requires (Dev)
- phpstan/phpstan: ^0.12.50
- squizlabs/php_codesniffer: ^3.4
README
This project implements a very simple Router based in php.
The configuration for it looks like this:
{
"/homepage": {
"GET": "homepage.php"
},
"/other_page": {
"*": "other_page.php"
}
}
This will allow only get methods on /homepage
and all methods on /other-page
.
All paths in the configuration must be relative to the index document mentioned in the usage section.
Usage
<?php
include 'vendor/autoload.php';
use JLanger\Router\Router;
use JLanger\Router\JsonRouteStorage;
(new Router(new JsonRouteStorage('config_file.json')))->doRouting($_SERVER);