marko / routing
Marko Framework Routing
0.11.0
2026-10-06 15:08 UTC
Requires
- php: ^8.5
- ext-fileinfo: *
- marko/config: 0.11.0
- marko/core: 0.11.0
Requires (Dev)
- marko/testing: 0.11.0
- pestphp/pest: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Attribute-based routing with automatic conflict detection---define routes on controller methods, not in separate files.
Installation
composer require marko/routing
Quick Example
use Marko\Routing\Attributes\Get; use Marko\Routing\Attributes\Post; use Marko\Routing\Attributes\RoutePrefix; use Marko\Routing\Exceptions\HttpException; use Marko\Routing\Http\Response; #[RoutePrefix('/shop', namePrefix: 'shop.')] class ProductController { #[Get('/products', name: 'products.index')] public function index(): Response { return new Response('Product list'); } #[Get('/products/{id:\d+}', name: 'products.show')] // $urlGenerator->route('shop.products.show', ['id' => 7]) public function show(int $id): Response { if ($id > 1000) { throw HttpException::notFound('Product not found.'); // 404, JSON or HTML } return new Response("Product $id"); } #[Post('/products')] public function store(): Response { return new Response('Created', 201); } }
Documentation
Full usage, API reference, and examples: marko/routing