PHPackages                             akido-ld/simple-route - 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. akido-ld/simple-route

ActiveLibrary[Framework](/categories/framework)

akido-ld/simple-route
=====================

A simple PHP routing library

v1.1.2(6mo ago)07PHPPHP ^8.1

Since Oct 3Pushed 6mo agoCompare

[ Source](https://github.com/AkidoLD/SimpleRoute)[ Packagist](https://packagist.org/packages/akido-ld/simple-route)[ RSS](/packages/akido-ld-simple-route/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

SimpleRoute
===========

[](#simpleroute)

> A PHP routing library based on a tree structure

Why SimpleRoute?
----------------

[](#why-simpleroute)

Traditional PHP routers (like Laravel or Symfony) use flat arrays to define routes.

**Problem:** With nested routes, the code quickly becomes repetitive and harder to maintain:

```
// Classic router
$routes = [
    '/api/users' => $usersHandler,
    '/api/users/profile' => $profileHandler,
    '/api/users/settings' => $settingsHandler,
];
```

**Solution:**SimpleRoute uses a **tree structure** that naturally reflects the hierarchy of URLs.

You can build your route tree in **two ways** 👇

### 🧱 Classic method (explicit)

[](#-classic-method-explicit)

```
$root->addChild($api);
$api->addChild($users);
$users->addChild($profile);
$users->addChild($settings);
```

### ⚡ Simplified method (modern)

[](#-simplified-method-modern)

```
$root = new Node('root');
$api = new Node('api', parent: $root);
$users = new Node('users', parent: $api);
$profile = new Node('profile', parent: $users);
$settings = new Node('settings', parent: $users);
```

**Result:** Cleaner code, no duplication, and a clear visual hierarchy.

---

✨ Features
----------

[](#-features)

- 🌳 **Tree-based structure** – Routes are organized hierarchically (parent/child), just like real URLs
- ⚡ **O(h) performance** – Fast route lookup based on tree depth
- ✅ **119 unit tests** – Reliable code with high coverage
- 🧠 **Type-safe (PHP 8.1+)** – Full type hints to prevent runtime errors
- 🧩 **Typed exceptions** – Each error has its own class for easier debugging
- 🪶 **Lightweight** – Zero external dependencies

---

🚀 Installation
--------------

[](#-installation)

### Via Composer (recommended)

[](#via-composer-recommended)

```
composer require akido-ld/simple-route
```

### Manual installation (for contributors)

[](#manual-installation-for-contributors)

```
git clone https://github.com/AkidoLD/SimpleRoute.git
cd SimpleRoute
composer install
```

---

🧩 Usage Example
---------------

[](#-usage-example)

```
use SimpleRoute\Router\{Node, NodeTree, Router, UriSlicer};

// Create nodes
$root = new Node('root');
$api = new Node('api', parent: $root);
$users = new Node('users', function() {
    echo json_encode(['users' => ['Alice', 'Bob']]);
}, parent: $api);

// Router setup
$tree = new NodeTree($root);
$router = new Router($tree);

// Match an URL
$uri = new UriSlicer('/api/users');
$router->dispatch($uri);

// Output: {"users":["Alice","Bob"]}
```

---

📚 Documentation
---------------

[](#-documentation)

- Check the [`/examples`](examples) directory for more usage examples
- See [`/tests`](tests) for detailed test cases and real-world usage patterns

---

🧪 Tests
-------

[](#-tests)

```
./vendor/bin/phpunit
```

**Stats:** 119 tests – high coverage ✅

To generate a coverage report:

```
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverage
```

---

📜 License
---------

[](#-license)

[MIT License](LICENSE)

---

👤 Author
--------

[](#-author)

**Akido LD**[GitHub: @AkidoLD](https://github.com/AkidoLD)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance66

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

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

Every ~3 days

Total

6

Last Release

205d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/278dc2df7b30c175818ff2c54f63ba755ae257fecbbaa325493eb437a6f5ca9c?d=identicon)[AkidoLD](/maintainers/AkidoLD)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/akido-ld-simple-route/health.svg)

```
[![Health](https://phpackages.com/badges/akido-ld-simple-route/health.svg)](https://phpackages.com/packages/akido-ld-simple-route)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[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.7M259](/packages/laravel-dusk)[laravel/prompts

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

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

A simple API extension for DateTime.

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

PHPackages © 2026

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