PHPackages                             dlpwd/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. dlpwd/router

ActiveLibrary

dlpwd/router
============

Lightweight router library with named url parameters

1.0.9(3y ago)11.5k↓50%1MITPHP

Since Aug 27Pushed 3y ago1 watchersCompare

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

READMEChangelog (10)DependenciesVersions (11)Used By (0)

dlpwd-router
============

[](#dlpwd-router)

Lightweight router library with named url parameters

Basic Usage
-----------

[](#basic-usage)

```
$router = new \dlpwd\router\Router();

$router->get('/', '\\dlpwd\\sample\\controller\\dashboard::renderDashboard');
$router->get('/login', '\\dlpwd\\sample\\controller\\login::showLoginForm');
$router->post('/login', '\\dlpwd\sample\\controller\\login::processLogin');
$router->get('/page/{friendlyUrl}', '\\dlpwd\\sample\\controller\\page::showPage');

$router->resolve();
```

Configuring Routes
------------------

[](#configuring-routes)

The router supports three request methods, GET, POST and DELETE. There are corresponding methods in the router class to add routes for each request method

```
Router::get($_url, $_handler);
Router::post($_url, $_handler);
Router::delete($_url, $_handler);
Router::addRoute($_method, $_url, $_handler);
```

### $\_method

[](#_method)

The request method can be specified when using the addRoute method on the router to create a new route. This method is useful when adding routes in bulk, for example after loading from a database or file, rather than using hard-coded routes.

### $\_url

[](#_url)

The URL for the route should be specified with a leading forward-slash. Trailing forward-slashes are optional. The router will match requests with and without a trailing forward-slash to the same route. Parameters are specified within curly-braces. The name of the parameters must match the name of the parameters on the handler function, otherwise they will not be passed through

### $\_handler

[](#_handler)

The handler argument specifies the function to call if the route matches. The function can be specified in as any valid PHP callable

Resolving Routes
----------------

[](#resolving-routes)

To have the router examine a URL and call the relevant controller, execute the resolve method. The resolve method will return any value returned by the controller function

```
Router::resolve($_url, $_method);
```

### $\_url

[](#_url-1)

Omitting or passing null to the $\_url parameter will cause the router to use the value of $\_SERVER\['REQUEST\_URI'\]. Pass a url to this argument to manually run the router for a different URL than the one being requested

### $\_method

[](#_method-1)

Omitting or passing null to the $\_method parameter will cause the router to use the value of $\_SERVER\['REQUEST\_METHOD'\]. Pass a method to this argument to override that value. Most useful when manually running the router with a different URL as above

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 54.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.

###  Release Activity

Cadence

Every ~90 days

Recently: every ~38 days

Total

10

Last Release

1280d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/30538d4f092f8456dca4122d0573ddaf6d4903ab8048447674e59b331eb9dc59?d=identicon)[davelegg](/maintainers/davelegg)

---

Top Contributors

[![DaveLegg](https://avatars.githubusercontent.com/u/1929446?v=4)](https://github.com/DaveLegg "DaveLegg (6 commits)")[![NeowinDave](https://avatars.githubusercontent.com/u/18385374?v=4)](https://github.com/NeowinDave "NeowinDave (4 commits)")[![mark-todd](https://avatars.githubusercontent.com/u/60781787?v=4)](https://github.com/mark-todd "mark-todd (1 commits)")

---

Tags

router

### Embed Badge

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

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

###  Alternatives

[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k789.4M1.8k](/packages/symfony-routing)[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.2k49.9M1.3k](/packages/slim-slim)[nikic/fast-route

Fast request router for PHP

5.3k92.4M668](/packages/nikic-fast-route)[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6633.1M115](/packages/league-route)[contributte/api-router

RESTful Router for your Apis in Nette Framework - created either directly or via attributes

20802.8k3](/packages/contributte-api-router)

PHPackages © 2026

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