Lightweight router for PHP applications

Installs: 26

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/codemonster-ru/router

v2.3.0 2025-10-19 16:24 UTC

This package is auto-updated.

Last update: 2025-10-19 16:25:26 UTC


README

Latest Version on Packagist Total Downloads License Tests

A lightweight router for PHP applications.

๐Ÿ“ฆ Installation

composer require codemonster-ru/router

๐Ÿš€ Usage

use Codemonster\Router\Router;

$router = new Router();

$router->get('/', fn() => 'Home Page');
$router->get('/about', fn() => 'About Us');

$result = $router->dispatch(
    $_SERVER['REQUEST_METHOD'],
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

if ($result === null) {
    http_response_code(404);

    echo 'Not Found';
} else {
    echo $result;
}

โœจ Features

  • Simple route registration (get, post, any)
  • Support for callbacks, [Controller::class, 'method'] controllers, and Controller@method strings
  • Returns a pure result, without binding to a specific Response

๐Ÿงช Testing

composer test

๐Ÿ‘จโ€๐Ÿ’ป Author

Kirill Kolesnikov

๐Ÿ“œ License

MIT