PHPackages                             ap-lib/routing - 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. ap-lib/routing

ActiveLibrary[Framework](/categories/framework)

ap-lib/routing
==============

High-performance, flexible PHP routing library designed for speed and extensibility. Routing is optimized for static method calls and relies on a pre-built index for maximum efficiency. It provides simple, direct hashmap-based routing while allowing custom strategies and middleware support.

059PHP

Since Jul 3Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/ap-lib/routing)[ Packagist](https://packagist.org/packages/ap-lib/routing)[ RSS](/packages/ap-lib-routing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AP\\Routing
===========

[](#aprouting)

[![MIT License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

**High-performance, flexible PHP routing library designed for speed and extensibility.**

Routing is optimized for static method calls and relies on a pre-built index for maximum efficiency. It provides simple, direct hashmap-based routing while allowing custom strategies and middleware support.

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

[](#installation)

```
composer require ap-lib/routing
```

Features
--------

[](#features)

- 🚀 **Performance-first** - Designed for minimal overhead, using direct static method calls
- ⚡ **Pre-built index** - Requires indexing routes in advance for the fastest possible lookups
- 🔗 **Static hashmap routing** - Default routing mechanism based on an ultra-fast hashmap index
- 🛠 **Extensible architecture** - Supports custom routing strategies through a plugin-like system
- 🔄 **Middleware support** - Easily add middleware for request processing and authentication

Requirements
------------

[](#requirements)

- PHP 8.3 or higher

Getting started
---------------

[](#getting-started)

### Base use case

[](#base-use-case)

```
#Handlers must be static methods
class MainController
{
    public static function handlerRoot(Request $request): Response
    {
        return new Response("main page");
    }

    public function handlerHelloName(Request $request): Response
    {
        $name = isset($request->get['name']) && is_string($request->get['name'])
            ? $request->get['name']
            : "guest";

        return new Response("Hello " . htmlspecialchars($name));
    }
}

// make routing
$routing = new Hashmap();

// setup index
$index = $routing->getIndexMaker();

$index->addEndpoint(Method::GET, "/", new Endpoint(
    [MainController::class, "handlerRoot"]
));

$index->addEndpoint(Method::GET, "/hello", new Endpoint(
    [MainController::class, "handlerHelloName"]
));

// init routing
$routing->init($index->make());

 // run `GET /`
try {
    $routingResult = $routing->getRoute(Method::GET, "/");
} catch (NotFound) {
    throw new Exception("ERROR NOT FOUND");
}

// execute handler + optional middlewares
$response = $routingResult->endpoint->run(
    request: new Request(
        method: Method::GET,
        path: "/",
        get: [],
        post: [],
        cookie: [],
        headers: [],
        files: [],
        body: "",
        params: $routingResult->params,
        ip: "127.0.0.1"
    )
);

/*
    AP\Routing\Response\Response Object (
        [body] => main page
        [code] => 200
    )
*/

// run `GET /hello?name=John`
try {
    $routingResult = $routing->getRoute(Method::GET, "/hello");
} catch (NotFound) {
    throw new Exception("ERROR NOT FOUND");
}

$response = $routingResult->endpoint->run(
    request: new Request(
        method: Method::GET,
        path: "/hello",
        get: ["name" => "John"],
        post: [],
        cookie: [],
        headers: [],
        files: [],
        body: "",
        params: $routingResult->params,
        ip: "127.0.0.1"
    )
);

/*
    AP\Routing\Response\Response Object
    (
        [body] => Hello John
        [code] => 200
    )
*/
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

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/1215fe5ecc9ba0ab1c730d3c992125cf6ebf460562e66be71ebae127789d465a?d=identicon)[AntonPanfilov](/maintainers/AntonPanfilov)

---

Top Contributors

[![anton-panfilov](https://avatars.githubusercontent.com/u/1083546?v=4)](https://github.com/anton-panfilov "anton-panfilov (26 commits)")

### Embed Badge

![Health badge](/badges/ap-lib-routing/health.svg)

```
[![Health](https://phpackages.com/badges/ap-lib-routing/health.svg)](https://phpackages.com/packages/ap-lib-routing)
```

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