PHPackages                             jdwx/trie - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jdwx/trie

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jdwx/trie
=========

v1.0.0(9mo ago)01631MITPHPPHP &gt;=8.3.0

Since Aug 13Pushed 8mo ago1 watchersCompare

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

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

trie-php
========

[](#trie-php)

An adaptive radix tree implementation for PHP. Optionally supports defining variables along the path.

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

[](#installation)

You can require it directly with Composer:

```
composer require jdwx/trie
```

Or download the source from GitHub:

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

[](#requirements)

This module requires PHP 8.3 or later. It has no other runtime dependencies.

Usage
-----

[](#usage)

This implementation is slower than PHP's built-in associative arrays for straight lookups. It provides significant advantages when variable detection and partial matches are required.

The Trie class provides the ArrayAccess interface, so it can be used as a drop-in replacement for arrays.

```
    $trie = new JDWX\Trie\Trie();
    $trie[ 'Foo' ] = 'FOO';
    $trie[ 'Foo/Bar' ] = 'BAR';
    $trie[ 'Foo/Bar/Baz' ] = 'BAZ';
    $trie[ 'Foo/Bar/Qux' ] = 'QUX';

    echo $trie[ 'Foo/Bar' ], "\n"; # => 'BAR'
    echo $trie[ 'Foo/Bar/Baz' ], "\n"; # => 'BAZ'
    echo $trie[ 'Foo/Bar/Baz/Quux' ] ?? '[null]', "\n"; # => [null]

    $trie = new JDWX\Trie\Trie( true );
    $trie[ 'Foo/${Bar}/Baz' ] = 'BAZ';

    echo $trie[ 'Foo/Qux/Baz' ], "\n"; # => 'BAZ'
    echo $trie->var( '$Bar' ), "\n"; # => 'Qux'
```

Stability
---------

[](#stability)

This module has been subsequently refactored and largely rewritten to provide substantially simpler usage and more functionality prior to its public release. Consequently, it is not yet considered stable, especially around variable handling. (The method previously used had certain limitations and was very error-prone.)

History
-------

[](#history)

This module was first adapted from a private codebase in May 2025.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance59

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

279d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdwx-trie/health.svg)

```
[![Health](https://phpackages.com/badges/jdwx-trie/health.svg)](https://phpackages.com/packages/jdwx-trie)
```

PHPackages © 2026

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