kavalanche / router
There is no license information available for the latest version (v1.0.0) of this package.
Router component for web applications
v1.0.0
2024-02-15 21:50 UTC
Requires (Dev)
- phpunit/phpunit: ^8.4
This package is auto-updated.
Last update: 2025-04-16 00:43:06 UTC
README
Simple routing library for web applications.
Usage
Require kavalanche/router
composer require kavalanche/router
Create
Router
instance.$router = new \Kavalanche\Router\Router();
Add your routes.
$router->get('/', function() { echo 'Start'; }); $router->get('/post(\d+)', function($id) { echo 'Post ' . $id; }); $router->get('/test/index', [Kavalanche\Router\TestController::class, 'index']); $controller = new Kavalanche\Router\TestController(); $router->get('/test/post/(\d+)', [$controller, 'post']);
Invoke
dispatch
method.$router->dispatch();