A lightweight router for PHP applications.
composer require codemonster-ru/routeruse Codemonster\Router\Router;
$router = new Router();
$router->get('/', fn() => 'Home Page');
$router->get('/about', fn() => 'About Us');
$result = $router->dispatch(
$_SERVER['REQUEST_METHOD'],
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
if ($result === null) {
http_response_code(404);
echo 'Not Found';
} else {
echo $result;
}- Simple route registration (
get,post,any) - Support for callbacks,
[Controller::class, 'method']controllers, andController@methodstrings - Returns a pure result, without binding to a specific
Response
composer test