falgunphp / routing
dev-master
2021-06-26 19:56 UTC
Requires
- php: ^7.4|^8.0
Requires (Dev)
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.5
- slevomat/coding-standard: ^6.4
- squizlabs/php_codesniffer: ^3.6
- vimeo/psalm: ^3.18
This package is auto-updated.
Last update: 2024-09-27 03:24:43 UTC
README
Simple Routing Library.
Install
Please note that PHP 7.4 or higher is required.
Via Composer
$ composer require falgunphp/routing
Usage
<?php use Falgun\Routing\Router; use Falgun\Routing\RequestContext; $router = new Router('http://localhost/'); $router->any('/')->action(HomeController::class, 'index'); $router->get('/test')->action(TestController::class, 'index'); // Fetch method and URI from somewhere $httpMethod = $_SERVER['REQUEST_METHOD']; $uri = $_SERVER['REQUEST_URI']; // create request context $requestContext = new RequestContext($uri, $httpMethod); /* @var $route RouteInterface */ $route = $this->router->dispatch($requestContext);
License
The MIT License (MIT). Please see License File for more information.