seeren / router
Route http requests to controller actions
3.1
2022-01-09 20:37 UTC
Requires
- php: >=8.0.1
- seeren/container: ^3.0
- seeren/controller: ^4.1
Requires (Dev)
- php-coveralls/php-coveralls: ^v2.5.2
- phpunit/phpunit: ^9.5
README
Route http requests to controller actions
Installation
composer require seeren/router
Seeren\Router\Router
namespace App\Controller; use Seeren\Controller\JsonController; use Seeren\Router\Route\Route; class FooController extends JsonController { #[Route("/path/(\d+)", "GET")] public function show(int $id) { return $this->render([]); } }
Retrieve \Psr\Http\Message\ResponseInterface
from a routed controller
use Seeren\Router\Router; $router = new Router(); $response = $router->getResponse();
Configuration
Router use container configuration to inject arguments as primitve: https://github.com/seeren/container#interfaces
project/ └─ config/ └─ services.json └─ routes.json
config/services.json
{ "parameters": {}, "services": {} }
Controllers are resolved using anotation by default or configuration file. Captured matches are passed to controller action that can either use autowire
config/routes.json
[ { "path": "/path/(\\d+)", "controller": "App\\Controller\\FooController::show" } ]
License
This project is licensed under the MIT License