PHPackages                             codesaur/router - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. codesaur/router

ActiveLibrary[Framework](/categories/framework)

codesaur/router
===============

Хөнгөн, хурдан, объект-суурьтай маршрутчиллын (routing) компонент

v5.1.1(2mo ago)1636↓50%1MITPHPPHP ^8.2.1CI passing

Since Mar 2Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/codesaur-php/Router)[ Packagist](https://packagist.org/packages/codesaur/router)[ Docs](https://github.com/codesaur-php)[ RSS](/packages/codesaur-router/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (41)Used By (1)

codesaur/router
===============

[](#codesaurrouter)

[![CI](https://github.com/codesaur-php/Router/actions/workflows/ci.yml/badge.svg)](https://github.com/codesaur-php/Router/actions/workflows/ci.yml)[![PHP Version](https://camo.githubusercontent.com/1015683ef28e870620edc19b6e22b456c0dc170c260fa4645905e93438f607a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322e312d3737374242342e7376673f6c6f676f3d706870)](https://www.php.net/)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)

Агуулга / Table of Contents
---------------------------

[](#агуулга--table-of-contents)

1. [Монгол](#1-%D0%BC%D0%BE%D0%BD%D0%B3%D0%BE%D0%BB-%D1%82%D0%B0%D0%B9%D0%BB%D0%B1%D0%B0%D1%80) | 2. [English](#2-english-description) | 3. [Getting Started](#3-getting-started)

---

1. Монгол тайлбар
-----------------

[](#1-монгол-тайлбар)

Хөнгөн, хурдан, объект-суурьтай маршрутчиллын (routing) компонент. Динамик параметрүүд, нэртэй маршрутууд, reverse routing зэрэг бүх шаардлагатай боломжуудыг дэмждэг.

`codesaur/router` нь **codesaur ecosystem**-ийн нэг хэсэг бөгөөд хөнгөн жинтэй, фрэймворкоос үл хамааран standalone байдлаар ашиглаж болох PHP routing компонент юм.

Багц нь дараах 3 үндсэн class-аас бүрдэнэ:

- **Router** - маршрут бүртгэх, тааруулах, URL үүсгэх үндсэн класс
- **RouterInterface** - router хэрэгжүүлэх шаардлагуудыг тодорхойлсон интерфэйс
- **Callback** - маршрутын callback болон параметрүүдийг хадгалах wrapper класс

### Дэлгэрэнгүй мэдээлэл

[](#дэлгэрэнгүй-мэдээлэл)

- [Бүрэн танилцуулга](docs/mn/README.md) - Суурилуулалт, хэрэглээ, жишээнүүд
- [API тайлбар](docs/mn/api.md) - Бүх метод, exception-үүдийн тайлбар
- [Шалгалтын тайлан](docs/mn/review.md) - Код шалгалтын тайлан

---

2. English description
----------------------

[](#2-english-description)

A lightweight, fast, object-oriented routing component. Supports dynamic parameters, named routes, reverse routing, and all essential routing features.

`codesaur/router` is part of the **codesaur ecosystem** and is a lightweight PHP routing component that can be used standalone, independent of any framework.

The package consists of the following 3 core classes:

- **Router** - main class for registering routes, matching requests, and generating URLs
- **RouterInterface** - interface defining the requirements for router implementations
- **Callback** - wrapper class for storing route callbacks and their parameters

### Documentation

[](#documentation)

- [Full Documentation](docs/en/README.md) - Installation, usage, examples
- [API Reference](docs/en/api.md) - Complete API documentation
- [Review](docs/en/review.md) - Code review report

---

3. Getting Started
------------------

[](#3-getting-started)

### Requirements

[](#requirements)

- PHP **8.2.1+**
- Composer

### Installation

[](#installation)

Composer ашиглан суулгана / Install via Composer:

```
composer require codesaur/router
```

### Quick Example

[](#quick-example)

```
use codesaur\Router\Router;

$router = new Router();

// Энгийн GET маршрут / Simple GET route
$router->GET('/hello', function() {
    echo 'Hello, World!';
});

// Динамик параметртэй маршрут / Route with dynamic parameters
$router->GET('/news/{int:id}', function(int $id) {
    echo "News ID: $id";
})->name('news-view');

// UTF-8 параметр / UTF-8 parameter (Cyrillic, CJK, etc.)
$router->GET('/search/{utf8:query}', function(string $query) {
    echo "Search: $query";
})->name('search');

// Маршрут тааруулах / Match route
$callback = $router->match('/news/10', 'GET');
if ($callback) {
    $callable = $callback->getCallable();
    $params = $callback->getParameters();
    \call_user_func_array($callable, $params);
}

// URL үүсгэх / Generate URL
$url = $router->generate('news-view', ['id' => 10]); // -> /news/10
```

### Running Tests

[](#running-tests)

Тест ажиллуулах / Run tests:

```
# Бүх тестүүдийг ажиллуулах / Run all tests
composer test

# Coverage-тэй тест ажиллуулах / Run tests with coverage
composer test:coverage
```

---

Changelog
---------

[](#changelog)

- [CHANGELOG.md](CHANGELOG.md) - Full version history

Contributing &amp; Security
---------------------------

[](#contributing--security)

- [Contributing Guide](.github/CONTRIBUTING.md)
- [Security Policy](.github/SECURITY.md)

License
-------

[](#license)

This project is licensed under the MIT License.

Author
------

[](#author)

**Narankhuu**

**codesaur ecosystem:**

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~20 days

Total

40

Last Release

70d ago

Major Versions

v1.2.1 → v2.02021-09-18

v2.2 → v3.02021-09-23

v3.4 → v4.02021-10-06

v4.6.0 → v5.0.02026-01-08

PHP version history (3 changes)v1.0PHP &gt;=7.2.0

v4.2.0PHP &gt;=8.2.1

v5.0.0PHP ^8.2.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2281c1b7b23007da57ad0526923a5f822dea64629ab1cb70749188d2b869e55c?d=identicon)[codesaur](/maintainers/codesaur)

---

Top Contributors

[![codesaur](https://avatars.githubusercontent.com/u/4127594?v=4)](https://github.com/codesaur "codesaur (59 commits)")

---

Tags

routerroutecodesaurmongolmongolianarankhuucodenкодзаврнаранхүүкоден

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codesaur-router/health.svg)

```
[![Health](https://phpackages.com/badges/codesaur-router/health.svg)](https://phpackages.com/packages/codesaur-router)
```

###  Alternatives

[pecee/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

696214.6k17](/packages/pecee-simple-router)[izniburak/router

simple router class for php

23522.6k7](/packages/izniburak-router)[ecoal95/php-router

Minimal routing library

271.0k1](/packages/ecoal95-php-router)[rosengate/exedra

Nestful route oriented PHP micro framework

142.0k1](/packages/rosengate-exedra)[developermarius/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

112.4k](/packages/developermarius-simple-router)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
