PHPackages                             highperapp/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. [HTTP &amp; Networking](/categories/http)
4. /
5. highperapp/router

ActiveLibrary[HTTP &amp; Networking](/categories/http)

highperapp/router
=================

Ultra-fast routing library optimized for microsecond response times

1.0.1(10mo ago)051MITPHPPHP ^8.3|^8.4

Since Jul 5Pushed 10mo agoCompare

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

READMEChangelog (2)Dependencies (13)Versions (3)Used By (1)

HighPer Router
==============

[](#highper-router)

[![PHP Version](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)](https://php.net)[![Performance](https://camo.githubusercontent.com/d1fcdb6720ada62de8c62eaeeb9b6dc9388e9d23aa70b28b56904440cd86dfe0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506572666f726d616e63652d4f2831292d6f72616e67652e737667)](https://github.com/highperapp/router)[![PSR-7](https://camo.githubusercontent.com/4675fc3a6bc2989f58b051892aa1b562984c15ec7155c4068863017a72fa345b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d372d436f6d70617469626c652d677265656e2e737667)](https://www.php-fig.org/psr/psr-7/)[![Tests](https://camo.githubusercontent.com/8578f1392f0d3c5aaff254a5d341a08ecceb1ce654347d545e042a001a398a5f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54657374732d3130302532352d737563636573732e737667)](https://github.com/highperapp/router)

**Ultra-fast hybrid Rust + PHP routing library with O(1) ring buffer cache and transparent fallback.**

### ⚡ **Ring Buffer Cache**

[](#-ring-buffer-cache)

- **O(1) Route Lookups**: Constant-time route resolution
- **RingBufferCache**: Smart eviction with 98,976+ operations handled
- **Zero Memory Leaks**: Confirmed stable memory usage
- **Intelligent Caching**: Automatic hot route prioritization

### 🎯 **Performance Optimizations**

[](#-performance-optimizations)

- **Hybrid Rust + PHP**: Ultra-fast Rust FFI engine with seamless PHP fallback
- **NO REGEX**: Simple string matching for maximum performance
- **Microsecond Response**: Sub-millisecond route matching (0.0002ms achieved)
- **Auto Engine Selection**: Automatically picks best available engine
- **Memory Efficient**: Minimal footprint even with thousands of routes
- **PSR-7 Compatible**: Works with any PSR-7 HTTP implementation
- **Parameter Constraints**: Built-in validation for route parameters

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

[](#installation)

```
composer require highperapp/router
```

### Optional: Build Rust Engine (for maximum performance)

[](#optional-build-rust-engine-for-maximum-performance)

```
# Navigate to rust directory
cd vendor/highperapp/router/rust

# Build the Rust FFI library
chmod +x build.sh
./build.sh

# Or install system-wide
./build.sh --install
```

The router will automatically detect and use the Rust engine if available, with transparent fallback to PHP.

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

[](#quick-start)

```
