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(7mo ago)01[1 issues](https://github.com/henningcullin/php-routing/issues)MITPHPPHP &gt;=8.1

Since Oct 10Pushed 6mo 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 1mo ago

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

28

—

LowBetter than 54% of packages

Maintenance65

Regular maintenance activity

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

211d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/708110ed77f8959d531435aaf58709b7f6bad683498a6fd810ff4b80ce5cae83?d=identicon)[henningcullin](/maintainers/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/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M529](/packages/laravel-passport)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

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

1.9k36.7M256](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)

PHPackages © 2026

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