markbaker/tries
Composer 安装命令:
composer require markbaker/tries
包简介
PHP Classes for Trie datastructures
README 文档
README
A PHP implementation of the Trie, RadixTrie and SuffixTrie data structures
Requirements
- PHP version 7.2 or higher
Installation
We recommend installing this package with 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
Although we strongly recommend using Composer, we also provide a Phar archive 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
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?
Fork this library!
License
Tries is licensed under an MIT LICENSE)
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 <name> <limit>or
php playerSearchRadixTrie <name> <limit>or
php playerSearchSuffixTrie <name> <limit>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 <searchterm> <limit>or
php wordSearchRadixTrie <searchterm> <limit>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 returnedNote that the dictionary of 160k words will take some time to load, depending on your system
markbaker/tries 适用场景与选型建议
markbaker/tries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.85k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2014 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「trie」 「datastructure」 「radix」 「suffix」 「patricia」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 markbaker/tries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 markbaker/tries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 markbaker/tries 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
QuadTree implementation in PHP
A "C struct"-like class with type safe attributes and fluent setter interface.
High-performance radix tree based HTTP request router
An implementation of the Directed Acyclic Graph (DAG) for Laravel models
DataTree: Tree data-structure component for Nette Framework
One of the fastest PHP router, using a radix trie to retrieve routes
统计信息
- 总下载量: 3.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-30