PHPackages                             csulok0000/routing - 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. csulok0000/routing

ActiveLibrary[Framework](/categories/framework)

csulok0000/routing
==================

012PHP

Since May 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/csulok0000/routing)[ Packagist](https://packagist.org/packages/csulok0000/routing)[ RSS](/packages/csulok0000-routing/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Routing
=======

[](#routing)

[![Status: in development](https://camo.githubusercontent.com/d2dbda5699a30da6b3acc9f74b612e441d0ba25631d7014a6389d427acfbaad8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374617475732d696e253230646576656c6f706d656e742d726564)](https://camo.githubusercontent.com/d2dbda5699a30da6b3acc9f74b612e441d0ba25631d7014a6389d427acfbaad8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374617475732d696e253230646576656c6f706d656e742d726564)

> ⚠️ This project is currently under development and **not recommended for production use**.

Simple PHP Router

Author: Tibor Csik

Install
-------

[](#install)

Install Composer and run following command in your project's root directory:

```
$ composer require csulok0000/routing "dev-main"
```

Getting Started
---------------

[](#getting-started)

```
use Csulok0000\Routing\Router;

$router = new Router();

$router->get('/', function () {
    echo "Home";
});

$router->get('/contents/{id}', function ($id) {
    echo "Content: $id";
});

try {
    $response = $route->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
} catch (Exception $e) {

}

$response?->send();
```

Routes
------

[](#routes)

```
use Csulok0000\Routing\Route;
use Csulok0000\Routing\Enums\Method;

// The HTTP method can be specified in several ways
new Route('GET', '/a/{b}', fn($b) => 'Hello ' . $b);
new Route(['GET'], '/a/{b}', fn($b) => 'Hello ' . $b);
new Route(Method::Get, '/a/{b}', fn($b) => 'Hello ' . $b);
new Route([Method::Get], '/a/{b}', fn($b) => 'Hello ' . $b);

// ...or multiple methods at once
new Route(['GET', 'POST'], '/a/{b}', fn($b) => 'Hello ' . $b);
```

There are also multiple ways to define the action:

```
new Route('GET', '/', fn($b) => 'Hello ' . $b);
new Route('GET', '/', [TestController::class, 'index']);
new Route('GET', '/', Closure::fromCallable([TestController::class, 'index']));
```

### Named Routes

[](#named-routes)

Routes can be given names, allowing us to reference them later — for example, when generating a URL.

```
new Route('GET', '/', fn($b) => 'Hello ' . $b, 'route1');
// or
(new Route('GET', '/', fn($b) => 'Hello ' . $b))->setName('route1');
```

Router class
------------

[](#router-class)

### Adding a route

[](#adding-a-route)

```
...
$router->addRoute(new Route('GET', '/', fn() => ''));
```

### Helper methods

[](#helper-methods)

The Router class includes several helper methods to simplify adding routes.

```
...
// For individual HTTP methods
$router->get('/', fn () => '');
$router->head('/', fn () => '');
$router->post('/', fn () => '');
$router->put('/', fn () => '');
$router->patch('/', fn () => '');
$router->delete('/', fn () => '');
$router->options('/', fn () => '');

// For all HTTP methods
$router->any('/', fn () => '');
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4752340?v=4)[csulok0000](/maintainers/csulok0000)[@csulok0000](https://github.com/csulok0000)

---

Top Contributors

[![csulok0000](https://avatars.githubusercontent.com/u/4752340?v=4)](https://github.com/csulok0000 "csulok0000 (6 commits)")

### Embed Badge

![Health badge](/badges/csulok0000-routing/health.svg)

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

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M298](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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