Download the PHP package sirix/mezzio-radixrouter without Composer
On this page you can find all versions of the php package sirix/mezzio-radixrouter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sirix/mezzio-radixrouter
More information about sirix/mezzio-radixrouter
Files in sirix/mezzio-radixrouter
Package mezzio-radixrouter
Short Description RadixRouter integration for Mezzio
License MIT
Informations about the package mezzio-radixrouter
Mezzio RadixRouter
RadixRouter integration for Mezzio, providing high-performance HTTP routing using a radix tree algorithm.
Installation
Install this package via Composer:
Requirements
- PHP 8.2–8.5
mezzio/mezzio-router3.20+ or 4.x
Features
- High-performance routing using a radix tree algorithm
- PSR-7 and PSR-15 compatible
- Supports route parameters and optional parameters
- Route caching for improved performance
- Fully compatible with Mezzio middleware architecture
- Compatible with Mezzio Router 3.20+ and 4.x
Usage
Basic Setup
There are two ways to set up RadixRouter in your Mezzio application:
Automatic Configuration (Recommended)
The easiest way to set up RadixRouter is to use the provided ConfigProvider, which automatically registers all necessary dependencies:
This will automatically register the RadixRouter as the default router implementation for your application.
Manual Configuration
Alternatively, you can manually update your dependencies configuration:
Route Configuration
Routes can be defined in your Mezzio application as usual:
Route default parameters
Set a route's defaults option to include values in the matched parameters when
the request path does not provide them:
For a request to /articles, the matched parameters contain format: json and
locale: en. For /articles/uk, the captured locale: uk overrides the
default, while format: json remains available.
Radix-specific route patterns
The Radix router supports a few convenient path patterns that may not be available in all Mezzio routers. Here are some examples:
-
Optional parameter at the end
-
Multiple optional parameters in sequence
- Trailing wildcard (catch-all) segment
Notes:
- Parameter names are defined with a preceding colon (:) and become request attributes.
- A question mark (?) makes the parameter optional.
- An asterisk (*) after a parameter name captures the remainder of the path as a single string.
- Use route names (third argument) as needed for URL generation or identification.
Caching Configuration
To enable route caching for improved performance:
Documentation
For more information about routing in Mezzio, please refer to the Mezzio routing documentation.
Benchmarks
Performance benchmarks comparing RadixRouter with other Mezzio routers (FastRoute, LaminasRouter) are available in the benchmark-comparison directory.
For detailed results and methodology, see benchmark-comparison/README.md.
Quick Results (33 routes, JIT=tracing)
| Rank | Router | Lookups/sec | Mem (KB) | Register (ms) |
|---|---|---|---|---|
| 1 | MezzioRadixRouterCached | 1,279,430 | 45.1 | 0.073 |
| 2 | MezzioRadixRouter | 1,256,213 | 178.7 | 0.149 |
| 3 | MezzioFastRouteCached | 294,001 | 42.9 | 0.111 |
| 4 | MezzioFastRoute | 137,812 | 137.6 | 0.194 |
| 5 | MezzioLaminasRouter | 56,560 | 371.0 | 0.483 |
MezzioRadixRouter is ~9x faster than FastRoute and ~22x faster than LaminasRouter in this test.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
- Sirix - Project maintainer
- Wilaak RadixRouter - The underlying radix tree router implementation
- Mezzio - The middleware framework
All versions of mezzio-radixrouter with dependencies
fig/http-message-util Version ^1.1.5
mezzio/mezzio-router Version ^3.20 || ^4.1
psr/container Version ^1.0 || ^2.0
psr/http-message Version ^1.0.1 || ^2.0.0
wilaak/radix-router Version ^3.5