PHPackages                             markbaker/tries - 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. markbaker/tries

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

markbaker/tries
===============

PHP Classes for Trie datastructures

2.0.0(7y ago)211.6k4[2 issues](https://github.com/MarkBaker/Tries/issues)MITPHPPHP ^7.0.0

Since Nov 6Pushed 5y ago3 watchersCompare

[ Source](https://github.com/MarkBaker/Tries)[ Packagist](https://packagist.org/packages/markbaker/tries)[ Docs](https://github.com/MarkBaker/Tries)[ RSS](/packages/markbaker-tries/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (4)Used By (0)

Tries
=====

[](#tries)

A PHP implementation of the Trie, RadixTrie and SuffixTrie data structures

Master: [![Build Status](https://camo.githubusercontent.com/b3aa8819e4ba59ff3a4a9927b258e12c3d46820f782cd3bf7e86087f8af02b0e/68747470733a2f2f7472617669732d63692e6f72672f4d61726b42616b65722f54726965732e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/MarkBaker/Tries)

Develop: [![Build Status](https://camo.githubusercontent.com/0192a8e54ecc314a690995049e977fc164f0f99809a7980b4c66834b54fce7be/68747470733a2f2f7472617669732d63692e6f72672f4d61726b42616b65722f54726965732e706e673f6272616e63683d646576656c6f70)](http://travis-ci.org/MarkBaker/Tries)

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

[](#requirements)

- PHP version 7.2 or higher

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

[](#installation)

We recommend installing this package with [Composer](https://getcomposer.org/ "Get Composer").

### Via composer

[](#via-composer)

In your project root folder, execute

```
composer require markbaker/tries:dev-master

```

You should now have the files `composer.json` and `composer.lock` as well as the directory `vendor` in your project directory.

You can then require the Composer autoloader from your code

```
require 'vendor/autoload.php';

```

Or, if you already have a composer.json file, then require this package in that file

```
"require": {
    "markbaker/tries": "dev-master"
}

```

and update composer.

```
composer update

```

### From Phar

[](#from-phar)

Although we strongly recommend using Composer, we also provide a [Phar archive](http://php.net/manual/en/book.phar.php "Read about Phar") builder that will create a Phar file containing all of the library code.

The phar builder script is in the repository root folder, and can be run using

```
php buildPhar.php

```

To use the archive, just require it from your script:

```
require 'Tries.phar';

```

### Standard Autoloader

[](#standard-autoloader)

If you want to run the code without using composer's autoloader, and don't want to build the phar, then required the `bootstrap.php` file from the repository in your code, and this will enable the autoloader for the library.

```
require 'bootstrap.php';

```

Want to contribute?
-------------------

[](#want-to-contribute)

Fork this library!

License
-------

[](#license)

Tries is licensed under an [MIT LICENSE)](https://github.com/MarkBaker/Tries/blob/master/LICENSE.md)

Examples
--------

[](#examples)

The /examples folder has two examples to demonstrate their use:

- playerSearch.php
- playerSearchRadixTrie.php
- playerSearchSuffixTrie.php

    allows a search on Wigan Warriors rugby league players based on surname, displaying the record of those that match the entered search criteria

    usage:

    ```
     php playerSearch

    ```

    or

    ```
     php playerSearchRadixTrie

    ```

    or

    ```
     php playerSearchSuffixTrie

    ```

    where

    ```
     name     the first few characters of the surname you want to
              search for (or characters from anywhere in the name
              if using the Suffix Trie search)
     limit    optional (default 8) limits the number of results
              returned

    ```
- wordSearch.php
- wordSearchRadixTrie.php

    searches an English dictionary for words, displaying those that match the entered search criteria

    usage:

    ```
     php wordSearch

    ```

    or

    ```
     php wordSearchRadixTrie

    ```

    where

    ```
     searchterm   can be a prefix*
                      e.g. "aba*" will return words beginning with "aba"
                  a *suffix
                      e.g. "*ose" will return words ending in "ose"
                  or a split*search criteria
                      e.g. "t*ly" will return words beginning with "t"
                           and ending in "ly"
     limit        optional (default 8) limits the number of results
                  returned

    ```

    Note that the dictionary of 160k words will take some time to load, depending on your system

###  Health Score

33

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

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

Total

2

Last Release

2684d ago

Major Versions

1.0.0 → 2.0.02018-11-14

PHP version history (2 changes)1.0.0PHP ^5.4.0|^7.0.0

2.0.0PHP ^7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b8457fa3227a7e8e38f0121f1fe254ec965133df93ae5ea8352c757adb98283?d=identicon)[PHPOffice](/maintainers/PHPOffice)

---

Top Contributors

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

---

Tags

suffixtriedatastructureradixpatricia

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/markbaker-tries/health.svg)

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

###  Alternatives

[abelzhou/php-trie-tree

Make a trie tree with php language.

21717.7k1](/packages/abelzhou-php-trie-tree)[aza/math

AzaMath - Anizoptera CMF mathematic component. Arbitrary precision arithmetic (for huge integers; BCMath wrapper) and universal convertor between positional numeral systems (supported bases from 2 to 62 inclusive, and systems with custom alphabet; pure PHP realisation, can use GMP and core PHP functions for speed optimization).

2021.8k1](/packages/aza-math)

PHPackages © 2026

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