PHPackages                             sirix/yii-radixrouter - 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. sirix/yii-radixrouter

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

sirix/yii-radixrouter
=====================

Yii router RadixRouter adapter

1.1.0(4mo ago)462MITPHPPHP 8.2 - 8.5CI passing

Since Jan 10Pushed 4mo agoCompare

[ Source](https://github.com/sirix777/yii-radixrouter)[ Packagist](https://packagist.org/packages/sirix/yii-radixrouter)[ Fund](https://buymeacoffee.com/sirix)[ GitHub Sponsors](https://github.com/sirix777)[ RSS](/packages/sirix-yii-radixrouter/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (13)Versions (4)Used By (0)

Yii Radix Router Adapter
========================

[](#yii-radix-router-adapter)

[![Latest Stable Version](https://camo.githubusercontent.com/ed8d1f4b527b7f2bf243f3d6bd9b58672caa4602793392ae7d39f2d593c82386/687474703a2f2f706f7365722e707567782e6f72672f73697269782f7969692d7261646978726f757465722f76)](https://packagist.org/packages/sirix/yii-radixrouter)[![Total Downloads](https://camo.githubusercontent.com/7e0692a10fd0b5b8d3c3817c86d534b1b16175793554becb0b67e30123131148/687474703a2f2f706f7365722e707567782e6f72672f73697269782f7969692d7261646978726f757465722f646f776e6c6f616473)](https://packagist.org/packages/sirix/yii-radixrouter)[![Latest Unstable Version](https://camo.githubusercontent.com/d8f9c55c9b790a99feb5e2b9b031abddc747cbc88ac76a112eabb0dab1abee33/687474703a2f2f706f7365722e707567782e6f72672f73697269782f7969692d7261646978726f757465722f762f756e737461626c65)](https://packagist.org/packages/sirix/yii-radixrouter)[![License](https://camo.githubusercontent.com/5dc677fe533ab39b0359ab8ea9eb384dea96237ca2557850e7d827573594d93d/687474703a2f2f706f7365722e707567782e6f72672f73697269782f7969692d7261646978726f757465722f6c6963656e7365)](https://packagist.org/packages/sirix/yii-radixrouter)[![PHP Version Require](https://camo.githubusercontent.com/a9910cd18943a5dc9099c549a9592822c73f5a2082ebc38061db71cf76bb8bcb/687474703a2f2f706f7365722e707567782e6f72672f73697269782f7969692d7261646978726f757465722f726571756972652f706870)](https://packagist.org/packages/sirix/yii-radixrouter)

A high-performance Radix Tree based router implementation for the Yii Framework (Yii3), using the [wilaak/radix-router](https://github.com/wilaak/radix-router) under the hood.

This package is based on the [yiisoft/router-fastroute](https://github.com/yiisoft/router-fastroute) implementation.

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

[](#installation)

The package can be installed with Composer:

```
composer require sirix/yii-radixrouter
```

Important

This package provides its own DI configuration for `UrlMatcherInterface` and `UrlGeneratorInterface`. To avoid "Duplicate key" errors during configuration building, you **must not** have another router implementation (like `yiisoft/router-fastroute`) enabled at the same time.

If you have `yiisoft/router-fastroute` installed, remove it:

```
composer remove yiisoft/router-fastroute
```

Route Formats
-------------

[](#route-formats)

This adapter supports both the standard Yii-style route patterns and the native Radix Router format.

### Yii-style Support

[](#yii-style-support)

You can use the familiar `{param}` syntax, including optional regex parts. The matcher automatically converts these into a format compatible with the underlying Radix Tree.

Warning

The underlying Radix Router does **not support regular expressions** for parameter matching. When using Yii-style syntax with regex (e.g., `{id:\d+}`), the regular expression part is **ignored and stripped** during conversion to Radix format. All parameters are treated as simple string segments.

Yii FormatInternal Radix FormatDescription`/post/{id}``/post/:id`Standard parameter`/user/{name:\w+}``/user/:name`Parameter with regex (regex is ignored)`/post/[{id}]``/post/:id?`Optional parameter`/site/post[/{id}]``/site/post/:id?`Optional segment`/site[/{name}[/{id}]]``/site/:name?/:id?`Nested optional segments### Native Radix Router Formats

[](#native-radix-router-formats)

For advanced use cases, you can use native Radix Router parameters directly in your route definitions.

Native FormatDescriptionExample`:param`Required parameter`/blog/:slug``:param?`Optional parameter`/archive/:year?``:param*`Optional wildcard (0 or more segments)`/downloads/:path*``:param+`Required wildcard (1 or more segments)`/assets/:file+`For more details on the native format, see the [Radix Router documentation](https://github.com/wilaak/radix-router).

Usage
-----

[](#usage)

The package is designed to work seamlessly with Yii3's DI container.

### DI Configuration

[](#di-configuration)

If you are using `yiisoft/config`, the configuration will be applied automatically. Otherwise, you can manually configure the `UrlMatcherInterface` and `UrlGeneratorInterface`.

### Parameters

[](#parameters)

Configuration is available via `params.php`:

```
return [
    'sirix/yii-radixrouter' => [
        'enableCache' => true,
        'saveToPhpFile' => true,
        'cacheKey' => 'routes-cache',
        'phpCachePath' => 'runtime/routes-cache.php',
        'encodeRaw' => true,
        'scheme' => null,
        'host' => null,
    ],
];
```

Benchmarks
----------

[](#benchmarks)

Performance benchmarks comparing Radix Router against FastRoute are available in the `benchmarks-comparison` directory. These benchmarks are adapted from the excellent work of [wilaak/radix-router](https://github.com/wilaak/radix-router) by [@wilaak](https://github.com/wilaak).

### Quick Start

[](#quick-start)

```
cd benchmark-comparison
composer install
php bench.php --all
```

### Available Test Suites

[](#available-test-suites)

SuiteRoutesDescription`simple`33Basic static and parameterized routes`avatax`256Real-world API routes from Avatax`bitbucket`177Real-world API routes from Bitbucket`huge`500Randomly generated complex routes### Available PHP Modes

[](#available-php-modes)

ModeDescription`JIT=tracing`PHP with JIT compiler (tracing mode)`OPcache`PHP with OPcache enabled`No OPcache`PHP without any optimizations### Run Commands

[](#run-commands)

```
# Run all benchmarks
php bench.php --all

# Run specific suite
php bench.php --suite=simple

# Run specific mode
php bench.php --mode="JIT=tracing"

# Run specific routers
php bench.php --router=YiiRadixRouterAdapter,YiiRadixRouterCachedAdapter
```

### Benchmark Results

[](#benchmark-results)

Note

Benchmark results may vary depending on hardware, PHP version, OS configuration, and other environment factors.

Note

These benchmarks were run inside a virtualization environment on a running machine. This cannot be considered a full test bench as resources are shared among all containers. Results may vary compared to dedicated hardware.

### Environment

[](#environment)

- **CPU**: 8 × Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
- **Memory**: 64Gb
- **PHP**: 8.2.29

#### simple (33 routes)

[](#simple-33-routes)

RankRouterModeLookups/secMem (KB)Register (ms)1**YiiRadixRouterPhpCache**JIT=tracing1,062,16165.10.0942**YiiRadixRouterCached**JIT=tracing1,038,986196.90.2433**YiiRadixRouter**JIT=tracing1,026,673211.80.1774**YiiRadixRouterCached**OPcache661,535193.30.2955**YiiRadixRouterPhpCache**OPcache661,07663.50.1446**YiiRadixRouter**OPcache625,778127.70.2007**YiiRadixRouter**No OPcache594,685649.21.5108**YiiRadixRouterCached**No OPcache585,544769.82.1679**YiiRadixRouterPhpCache**No OPcache567,784668.01.54010**YiiFastRouteCached**JIT=tracing546,878102.40.22411**YiiFastRouteCached**OPcache429,62399.10.19112**YiiFastRouteCached**No OPcache406,177656.92.13513**YiiFastRoute**JIT=tracing116,380181.20.22114**YiiFastRoute**No OPcache89,250608.11.80615**YiiFastRoute**OPcache89,037100.90.266For detailed methodology, full results for all suites (`avatax`, `bitbucket`, `huge`), and more information, see [benchmark-comparison/README.md](benchmark-comparison/README.md).

License
-------

[](#license)

The Yii Radix Router is free software. It is released under the terms of the MIT License. Please see [LICENSE](LICENSE) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance75

Regular maintenance activity

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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 ~39 days

Total

2

Last Release

135d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ecccf9003c061847e877eeea3bdf1b382f6f9dbb11d33112d6b2740bf0533f9?d=identicon)[sirix777](/maintainers/sirix777)

---

Top Contributors

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

---

Tags

routeryiiyii3radixradix treeRadixRouter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sirix-yii-radixrouter/health.svg)

```
[![Health](https://phpackages.com/badges/sirix-yii-radixrouter/health.svg)](https://phpackages.com/packages/sirix-yii-radixrouter)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185702.8k44](/packages/laudis-neo4j-php-client)[mimmi20/browser-detector

Library to detect Browsers and Devices

48157.5k5](/packages/mimmi20-browser-detector)

PHPackages © 2026

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