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

ActiveLibrary[Framework](/categories/framework)

dv-team/router
==============

A simple routing library

0656PHP

Since Feb 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dv-team/php-router)[ Packagist](https://packagist.org/packages/dv-team/router)[ RSS](/packages/dv-team-router/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Usage Documentation for Router Class

The `Router` class is used to define and manage routes in a PHP application. It allows you to define routes for different HTTP methods and generate URLs based on these routes.

Example usage:

```
use DvTeam\Routing\Router;
use Psr\EventDispatcher\EventDispatcherInterface;

$router = new Router(
    webRoot: '/',
    httpHost: 'example.org', // From $_SERVER['HTTP_HOST']
    isHttps: true, // From $_SERVER['HTTPS']
    $dispatcher // A EventDispatcherInterface instance
);

// Define routes
$router->get(
    alias: 'home.index',
    urlPart: 'home',
    callable: [HomeController::class, 'index']
);

$router->get(
    alias: 'product.details',
    urlPart: 'details',
    callable: [ProductController::class, 'showDetails'],
    params: ['id']
);

$router->post(alias: 'submit', urlPart: 'submit', callable: [FormController::class, 'submit']);

// Generate a URL for a route
$url = $router->linkTo(['alias' => 'home']);
echo $url; // Outputs: https://example.org/home

// Generate a URL for a controller/method pair
$url = $router->linkTo(['@target' => [ProductController::class, 'showDetails'], 'id' => 123]);
echo $url; // Outputs: https://example.org/details/123

// Enter a context
$result = $router->enterContext(['alias' => 'product.details'], function(Router $router) {
    // Your code here
    return $router->linkToSelf(['id' => 123]);
});
echo $result; // Outputs: https://example.org/details/123
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity16

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://www.gravatar.com/avatar/cf998d17114530b943a1e99eb63b62ec349c0546c92eb5794e33141ad02ed434?d=identicon)[dv-team](/maintainers/dv-team)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[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.7M259](/packages/laravel-dusk)[laravel/prompts

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

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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