alpha-zeta / route
Fast and flexible routing library
1.0.5
2024-09-26 11:50 UTC
Requires
- php: ^8.2
Requires (Dev)
- httpsoft/http-message: ^1.0
- httpsoft/http-response: ^1.0
- httpsoft/http-runner: ^1.0
- httpsoft/http-server-request: ^1.0
- mockery/mockery: ^1.6
- phpunit/phpunit: ^11
README
Fast and flexible routing library
Install
composer require alpha-zeta/route
Usage
use Az\Route\RouteCollectionInterface; use App\Http\Conroller\Home; use App\Http\Conroller\Image; ... class App { private RouteCollectionInterface $route; public function __construct(RouteCollectionInterface $route, ...) { $this->route = $route; ... } public function run() { $this->route->get('/hello', function () { return 'Hello, World!'; }); $this->route->conroller('/image/{id}/{action?}/{slug?}', Image::class, 'image') ->tokens([ 'id' => '\d+', 'action' => 'thumbnail|origin|', ]); $this->route->get('/', [Home::class, 'index'], 'home') ->pipe(AuthMiddleware::class); $response = $this->pipeline->process($this->request, $this->defaultHandler); $this->emitter->emit($response); } }