PHPackages                             pivotphp/core-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. pivotphp/core-routing

ActiveLibrary[Framework](/categories/framework)

pivotphp/core-routing
=====================

Modular, high-performance routing system for PivotPHP - Express.js-inspired API with PSR compliance

1.0.0(6mo ago)0351MITPHPPHP ^8.1

Since Nov 15Pushed 6mo agoCompare

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

READMEChangelog (1)Dependencies (11)Versions (2)Used By (1)

PivotPHP Core Routing
=====================

[](#pivotphp-core-routing)

[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![PSR-7](https://camo.githubusercontent.com/093b4fa5b9e17b071aa98bab1140c0a9926d63f0594ee718bf49399abe413094/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d372d636f6d706c69616e742d627269676874677265656e)](https://www.php-fig.org/psr/psr-7/)[![PSR-15](https://camo.githubusercontent.com/691dda4a3402d15b181a541bd66a0a694410a065a70021faf5182c9e53c29190/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d31352d636f6d706c69616e742d627269676874677265656e)](https://www.php-fig.org/psr/psr-15/)

Modular, high-performance routing system for PivotPHP with Express.js-inspired API and full PSR compliance.

Features
--------

[](#features)

- **Express.js-Inspired API**: Familiar routing patterns (`get()`, `post()`, `put()`, `delete()`, etc.)
- **High Performance**: Multi-level caching, route indexing, and memory optimization
- **PSR Compliant**: Full PSR-7 (HTTP), PSR-15 (Middleware), PSR-6/PSR-16 (Cache) support
- **Plugin System**: Extensible architecture with built-in plugins
- **File Caching**: Persistent route compilation for faster startup
- **Static File Serving**: Express-style static file management
- **Type Safety**: Strict typing with PHPStan Level 9 compliance
- **Modular**: Use independently or integrate with PivotPHP Core

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

[](#installation)

```
composer require pivotphp/core-routing
```

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

[](#quick-start)

```
use PivotPHP\Routing\Router;

// Create router instance
$router = new Router();

// Define routes
$router->get('/users', function($req, $res) {
    return $res->json(['users' => []]);
});

$router->post('/users', [UserController::class, 'store']);

// Route with parameters
$router->get('/users/:id', function($req, $res) {
    $userId = $req->param('id');
    return $res->json(['user' => ['id' => $userId]]);
});

// Route groups with prefix and middleware
$router->group('/api', function() use ($router) {
    $router->get('/status', function($req, $res) {
        return $res->json(['status' => 'ok']);
    });
}, $authMiddleware);

// Match route
$route = $router::identify($method, $path);
```

Advanced Features
-----------------

[](#advanced-features)

### Plugin System

[](#plugin-system)

```
use PivotPHP\Routing\Plugins\MetricsPlugin;

$router->registerPlugin(new MetricsPlugin());
```

### File Caching

[](#file-caching)

```
use PivotPHP\Routing\Cache\FileCacheStrategy;

$cache = new FileCacheStrategy('/path/to/cache');
$router->setCacheStrategy($cache);

// Warm cache
$router->warmCache();
```

### Static Files

[](#static-files)

```
use PivotPHP\Routing\Static\StaticFileManager;

$router->static('/public', __DIR__ . '/public');
```

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

[](#requirements)

- PHP 8.1 or higher
- PSR-7 HTTP Message implementation
- PSR-15 HTTP Server Handler implementation

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Run with coverage
composer test:coverage

# Static analysis
composer phpstan

# Code style check
composer cs:check

# Fix code style
composer cs:fix

# All quality checks
composer quality:check
```

Performance
-----------

[](#performance)

PivotPHP Core Routing is designed for high performance:

- **Multi-level caching**: Exact match, compiled routes, pattern cache
- **Route indexing**: O(1) group lookups, method-based indexing
- **Memory management**: Automatic garbage collection, usage tracking
- **Static/Dynamic separation**: Optimized matching strategies

Documentation
-------------

[](#documentation)

- [Full Documentation](https://pivotphp.com/docs/routing)
- [Migration Guide](UPGRADE.md)
- [Plugin Development](docs/plugins.md)
- [Performance Tuning](docs/performance.md)

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) file for details.

Community
---------

[](#community)

- [GitHub Issues](https://github.com/PivotPHP/pivotphp-core-routing/issues)
- [Contributing](CONTRIBUTING.md)

Credits
-------

[](#credits)

Created by Carlos Fernandes and the PivotPHP community.

Inspired by Express.js routing and built with modern PHP best practices.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance68

Regular maintenance activity

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

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

184d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

psr-7phpframeworkrouterroutingpsr-15expresspivotphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pivotphp-core-routing/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[chubbyphp/chubbyphp-framework

A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

13544.4k4](/packages/chubbyphp-chubbyphp-framework)[igniphp/framework

Swoole, PSR-7, PSR-15 modular micro anti-framework.

2651.0k1](/packages/igniphp-framework)

PHPackages © 2026

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