PHPackages                             lorlev/aho-corasick - 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. lorlev/aho-corasick

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

lorlev/aho-corasick
===================

An implementation of the Aho-Corasick string matching algorithm.

v1.0.1(3y ago)0131Apache-2.0PHPPHP &gt;=7.4.3

Since Apr 20Pushed 3y agoCompare

[ Source](https://github.com/lorlev/AhoCorasick)[ Packagist](https://packagist.org/packages/lorlev/aho-corasick)[ Docs](https://gerrit.wikimedia.org/g/AhoCorasick)[ RSS](/packages/lorlev-aho-corasick/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (2)Used By (0)

[![Packagist.org](https://camo.githubusercontent.com/ca5f8213d26b78131299e34981edb72f345b2e6c493fa2e9d59d572d40a479e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77696b696d656469612f61686f2d636f72617369636b2e7376673f7374796c653d666c6174)](https://packagist.org/packages/wikimedia/aho-corasick)

AhoCorasick
===========

[](#ahocorasick)

AhoCorasick is a PHP implementation of the [Aho-Corasick](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm) string search algorithm, which is an efficient way of searching a body of text for multiple search keywords.

Here is how you use it:

```
use AhoCorasick\MultiStringMatcher;

$keywords = new MultiStringMatcher( array( 'ore', 'hell' ) );

$keywords->searchIn( 'She sells sea shells by the sea shore.' );
// Result: array( array( 15, 'hell' ), array( 34, 'ore' ) )

$keywords->searchIn( 'Say hello to more text. MultiStringMatcher objects are reusable!' );
// Result: array( array( 4, 'hell' ), array( 14, 'ore' ) )
```

Features
--------

[](#features)

The algorithm works by constructing a finite-state machine out of the set of search keywords. The time it takes to construct the finite state machine is proportional to the sum of the lengths of the search keywords. Once constructed, the machine can locate all occurences of all search keywords in any body of text in a single pass, making exactly one state transition per input character.

Contribute
----------

[](#contribute)

- Issue tracker:
- Source code:

Support
-------

[](#support)

If you are having issues, [please let us know](https://phabricator.wikimedia.org/maniphest/task/create/?projects=PHID-PROJ-hs5ausnvlfs4e3n5gmzg).

License
-------

[](#license)

The project is licensed under the Apache license.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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

1170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5dd43907328533de6cb788b26fb439924da441d9e9c4afdd1365811b337e7c60?d=identicon)[lorlev](/maintainers/lorlev)

---

Top Contributors

[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (8 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (7 commits)")[![atdt](https://avatars.githubusercontent.com/u/376462?v=4)](https://github.com/atdt "atdt (6 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (6 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (4 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (3 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (1 commits)")[![maksimovic](https://avatars.githubusercontent.com/u/1126226?v=4)](https://github.com/maksimovic "maksimovic (1 commits)")[![miguelxpn](https://avatars.githubusercontent.com/u/12788275?v=4)](https://github.com/miguelxpn "miguelxpn (1 commits)")

---

Tags

matcherahocorasick

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lorlev-aho-corasick/health.svg)

```
[![Health](https://phpackages.com/badges/lorlev-aho-corasick/health.svg)](https://phpackages.com/packages/lorlev-aho-corasick)
```

###  Alternatives

[wikimedia/aho-corasick

An implementation of the Aho-Corasick string matching algorithm.

584.0M7](/packages/wikimedia-aho-corasick)[ptrofimov/matchmaker

Ultra-fresh PHP matching functions

28170.0k](/packages/ptrofimov-matchmaker)

PHPackages © 2026

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