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

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

wikimedia/aho-corasick
======================

An implementation of the Aho-Corasick string matching algorithm.

v2.0.0(2y ago)573.5M—4.7%112Apache-2.0PHPPHP &gt;=7.4.3

Since Nov 23Pushed 2mo ago16 watchersCompare

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

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

[![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.

The algorithm originates from ["Efficient string matching: an aid to bibliographic search"](https://doi.org/10.1145/360825.36085) (CACM, Volume 18, Issue 6, June 1975) by Alfred V. Aho and Margaret J. Corasick.

See also the definition and reference implementation on [nist.gov](http://xlinux.nist.gov/dads/HTML/ahoCorasick.html).

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

55

—

FairBetter than 98% of packages

Maintenance56

Moderate activity, may be stable

Popularity56

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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

Every ~1459 days

Total

3

Last Release

910d ago

Major Versions

v1.0.1 → v2.0.02023-11-20

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.3

v1.0.1PHP &gt;=5.5.9

v2.0.0PHP &gt;=7.4.3

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

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

---

Top Contributors

[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (10 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (9 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (7 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)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (3 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)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (1 commits)")

---

Tags

aho-corasickahocorasickalgorithmmatcherahocorasick

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ptrofimov/matchmaker

Ultra-fresh PHP matching functions

27167.7k](/packages/ptrofimov-matchmaker)

PHPackages © 2026

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