falgunphp/routing

Installs: 65

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/falgunphp/routing

dev-master 2021-06-26 19:56 UTC

This package is auto-updated.

Last update: 2025-09-27 05:21:29 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.