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

ActiveLibrary[Framework](/categories/framework)

henningcullin/php-routing
=========================

A lightweight PHP routing library

v0.1.0(8mo ago)01[1 issues](https://github.com/henningcullin/php-routing/issues)MITPHPPHP &gt;=8.1

Since Oct 10Pushed 8mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Routing
===========

[](#php-routing)

A minimal routing library for PHP, inspired by [Rust Axum](https://docs.rs/axum/).

---

> ⚠️ **Warning:** This library is in early development (pre-1.0).
> APIs and behavior may change without notice. Use at your own risk.

---

Features
--------

[](#features)

- **Fast and lightweight** – minimal dependencies, small footprint.
- **Flexible route matching** – supports static paths, named parameters, optional segments, and wildcard routes.
- **HTTP method routing** – GET, POST, PUT, PATCH, DELETE, and more.
- **Route nesting** – prefix groups of routes cleanly.
- **Fallback and 404 handling** – default or path-specific fallbacks.
- **Middleware support** – wrap routes or all routes in a layer.
- **Request state propagation** – attach custom state objects to requests.
- **Convenient response helpers** – `json()`, `text()`, `redirect()`, and `problem()` responses.
- **Cookie and header management** – structured response headers and cookies.
- **View integration** – simple PHP views with layout support.
- **Helmet support** – manage `` tags programmatically.
- **Modern PHP 8+ syntax** – typed properties, enums, union types, and match expressions.
- **Composer-ready** – integrates easily into existing projects.

---

Installation
------------

[](#installation)

Install via Composer:

```
composer require henningcullin/php-routing
```

---

Setup
-----

[](#setup)

All requests should be routed through a single entry point (`index.php` or `main.php`). Use a rewrite rule in your web server:

### Apache `.htaccess` example

[](#apache-htaccess-example)

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
```

### Nginx example

[](#nginx-example)

```
location / {
   try_files $uri /index.php?$query_string;
}
```

---

Example Usage
-------------

[](#example-usage)

```
require_once __DIR__ . '/vendor/autoload.php';

use Routing\Router;
use Routing\Response;
use Routing\StatusCode;

// Create a router instance
$router = Router::new();

// Define routes
$router
    ->route('/hello/:name', Routing\get(function ($params) {
        return Response::text("Hello, " . $params['name']);
    }))
    ->route('/json', Routing\get(function () {
        return Response::json(['message' => 'Hello, JSON']);
    }));

// Define a fallback
$router->fallback(function () {
    return Response::text("Page not found", StatusCode::NOT_FOUND);
});

// Listen for requests
$router->listen();
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance59

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

267d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/78604659?v=4)[Sgt. Cullin](/maintainers/henningcullin)[@henningcullin](https://github.com/henningcullin)

---

Top Contributors

[![henningcullin](https://avatars.githubusercontent.com/u/78604659?v=4)](https://github.com/henningcullin "henningcullin (343 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/dusk

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

1.9k39.6M297](/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)
