PHPackages                             ldl-framework/http-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. ldl-framework/http-router

ActiveLibrary[Framework](/categories/framework)

ldl-framework/http-router
=========================

LDL HTTP Router

05285[1 PRs](https://github.com/ldl-php/ldl-http-router/pulls)PHP

Since Aug 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ldl-php/ldl-http-router)[ Packagist](https://packagist.org/packages/ldl-framework/http-router)[ RSS](/packages/ldl-framework-http-router/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (10)Used By (0)

\#LDL Http Router

A router based on phroute (for now)
-----------------------------------

[](#a-router-based-on-phroute-for-now)

LDL Http Router is a type of URL router which uses a chain of responsibility for pre, main, and post dispatchers.

### Single "controller" (Dispatcher)

[](#single-controller-dispatcher)

Routes consist of a main dispatcher class, which (ideally) contains a single dispatch method (plus needed dependencies injected via \_\_construct or other methods).

By having just a "single controller" class with the dispatch method, all other logic such as user validation or other pre conditions can be simplified in a single pre dispatcher and reused among other routes.

### Response parsers

[](#response-parsers)

Route dispatchers return data, just like any regular PHP method, and they are not allowed to modify the response body. For that, route dispatchers exist, which basically take in all the data from a request (pre, main and post dispatchers) and transform it to a string representation.

By default, this router focuses on REST type responses and thus, the results from the entire route will be JSON encoded, however other types of responses can be provided, for example using straight HTML.

Please see the [Template response parser](https://github.com/pthreat/ldl-http-router-template) plugin if you need any kind of templating, this plugin makes it possible to use any kind of templating engine you desire.

### Pre and post dispatchers

[](#pre-and-post-dispatchers)

These are actions that come before (pre) or after (post) the main dispatcher execution.

Pre and post dispatchers can be specified at:

- Router level (all routes will apply said pre and post dispatchers)
- Route level (only one or more routes implement some pre and post dispatch handlers)

All pre and post dispatchers are part of a middleware chain collection, each element of this collection has:

- A namespace and a name, with this in mind, no dispatchers compete with other dispatchers in the HTTP Response
- A priority, which establishes the order of execution of the middleware chain
- An active flag, to enable or disable a dispatcher

### Exception handlers

[](#exception-handlers)

Exception handlers are used when an exception is thrown from any type of dispatcher (be it pre, main or post) with exception handlers the developer can act on certain types of exceptions thrown and be able to provide a proper HTTP Response code, plus doing other actions, such as error logging, etc.

If an exception for which no exception handler exists is thrown, then the exception will simply throw a fatal error as expected.

Exception handlers can also be applied at:

- A router level (for example, when a route is not found)
- A route level (for example, when you want to handle a custom exception on a single route)

### Route configuration file

[](#route-configuration-file)

You can add any route you like to the router object manually, however this is discouraged. For this purpose you can add a routes.json configuration file with your own route definitions.

[Check this example](https://github.com/pthreat/ldl-http-router/blob/master/example/routes.json) to know how to define a route in a json configuration file.

### Useful plugins

[](#useful-plugins)

- [Authentication plugin](https://github.com/pthreat/ldl-http-router-auth)
- [Cache plugin](https://github.com/pthreat/ldl-http-router-cache)
- [Schema/Parameter validation plugin](https://github.com/pthreat/ldl-http-router-schema)
- [Template response parser](https://github.com/pthreat/ldl-http-router-template)

### Examples

[](#examples)

[Make sure to check the examples at the example folder](https://github.com/pthreat/ldl-http-router/blob/master/example)

### TODO

[](#todo)

- Add other config file parsers such as YML or XML
- Add more documentation regarding routes.json

### Bugs

[](#bugs)

If you'd like to report a bug, please open an issue here at our github page

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.5% 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://www.gravatar.com/avatar/c58f421340779f50b5cf5e0e1f0501692ee5141889dbe406509d795f0a728e3e?d=identicon)[pthreat](/maintainers/pthreat)

---

Top Contributors

[![pthreat](https://avatars.githubusercontent.com/u/8527076?v=4)](https://github.com/pthreat "pthreat (56 commits)")[![gonzalo-coda](https://avatars.githubusercontent.com/u/120412788?v=4)](https://github.com/gonzalo-coda "gonzalo-coda (27 commits)")

### Embed Badge

![Health badge](/badges/ldl-framework-http-router/health.svg)

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

###  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.7M255](/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)
