diego03 / router
A simpler php router
1.0.1
2024-02-10 21:22 UTC
Requires
- diego03/path-to-regexp: 1.0.2
Requires (Dev)
- pestphp/pest: ^2.32
README
A very simpler and without opnion router. is a good library for integrate with your framework.
basic usage
A simpler example of a json api:
<?php require __DIR__ . '/../vendor/autoload.php'; use Diego03\Router\Router; $router = new Router(); $router->get('/', function () { return [ 'message' => 'Hello World!' ]; }); $router->get('/users/:id', function ($id) { return [ 'id' => $id ]; }); $route = $router->match( $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] ); echo json_encode( $route['handler']( ...$route['params'] ) );
Feature roadmap
- Support all basic http methods
- path params
- Group routing
- Domain routing
- Middlewares