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

ActiveLibrary[Framework](/categories/framework)

switon/router
=============

Attribute-discovered routes, route tables, and literal and dynamic path matching for Switon Framework

v1.0.0(1mo ago)0255MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/router)[ Packagist](https://packagist.org/packages/switon/router)[ Docs](https://github.com/switon-php/router)[ RSS](/packages/switon-router/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (2)Used By (5)

Switon Router Package
=====================

[](#switon-router-package)

[![CI](https://camo.githubusercontent.com/fd6e2dd977c0b453759efd70013305358b35cbdb6acf07f1a64518566e75d4d5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f726f757465722f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/router/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's route matcher for literal and dynamic paths, attribute discovery, prefix-aware matching, and route resolution events.

Highlights
----------

[](#highlights)

- **Attribute-based routing:** controllers and actions declare routes in place with `#[RequestMapping]` and method mappings.
- **Prefix-aware discovery:** controller prefixes can be derived from names or set explicitly.
- **Path mapping rules:** `''`, relative, absolute, and array paths all map cleanly to routes.
- **View mappings:** `#[ViewGetMapping]` and related attributes can add GET views beside write actions.
- **Fast route lookup:** literal routes stay in hash lookups while dynamic ones compile to regex.
- **Match visibility:** `RouteNotFound` and `RouteParamsResolved` expose misses and parameter resolution.

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

[](#installation)

```
composer require switon/router
```

Quick Start
-----------

[](#quick-start)

```
use Switon\Routing\Attribute\GetMapping;
use Switon\Routing\Attribute\RequestMapping;

#[RequestMapping('/user')]
class UserController
{
    #[GetMapping('{id}')]
    public function showAction(int $id): array
    {
        return ['id' => $id];
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance87

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (8 commits)")

---

Tags

pathsrouterroutingswitonrouterroutingpathsswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[klein/klein

A lightning fast router for PHP

2.7k1.1M31](/packages/klein-klein)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M425](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M600](/packages/shopware-core)[pecee/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

675231.0k18](/packages/pecee-simple-router)[izniburak/router

simple router class for php

23323.5k7](/packages/izniburak-router)

PHPackages © 2026

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