kavan / routing
Simple HTTP router build on top of league/route
dev-main
2022-03-06 16:22 UTC
Requires
- laminas/laminas-diactoros: ^2.8
- laminas/laminas-httphandlerrunner: ^2.1
- league/route: ^5.1
This package is auto-updated.
Last update: 2024-11-06 23:47:29 UTC
README
Simple package made on top of league/route to handle routing in HTTP Requests.
Usage
<?php declare(strict_types=1); include 'path/to/vendor/autoload.php'; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; $httpApp = new Kavan\Routing\HttpApplication(); $httpApp->router->post('/user', function(ServerRequestInterface $request): ResponseInterface { $response = new Laminas\Diactoros\Response\JsonResponse; $response->setBody([ 'foo' => 'bar' ]); return $response; }); $httpApp->start();