PHPackages                             kellegous/codeowners - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kellegous/codeowners

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kellegous/codeowners
====================

Parsing and matching of Github's CODEOWNERS file format

1.1.0(1y ago)3122MITPHPPHP &gt;=7.4

Since Oct 21Pushed 10mo ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (5)Used By (0)

CODEOWNERS
==========

[](#codeowners)

This provides a parser and a set of matchers for the [CODEOWNERS file format](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).

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

[](#installation)

via [Composer](https://getcomposer.org/)

```
composer require kellegous/codeowners
```

Usage
-----

[](#usage)

### SimpleMatcher

[](#simplematcher)

The [SimpleMatcher](src/SimpleMatcher.php) is a straight-forward implementation of a [RuleMatcher](src/RuleMatcher.php)that can find the relevant pattern for a file path in `O(N)` time relative to the number of rules in the `CODEOWNERS`file.

```
$owners = Owners::fromFile('.github/CODEOWNERS');
$matcher = new SimpleMatcher($owners->getRules());
$rule = $matcher->match($relative_path);
```

### AutomataMatcher

[](#automatamatcher)

The [AutomataMatcher](src/AutomataMatcher.php) is a more complex implementation of a [RuleMatcher](src/RuleMatcher.php)that requires a bit more memory that the `SimpleMatcher` but is able to do matching in `O(log N)` time relative to the number of rules in the `CODEOWNERS` file.

```
$owners = Owners::fromFile('.github/CODEOWNERS');
$matcher = AutomataMatcher::build($owners->getRules());
$rule = $matcher->match($relative_path);
```

#### What does the AutomataMatcher do?

[](#what-does-the-automatamatcher-do)

Each of the patterns in a `CODEOWNERS` rule is a simplified regular expression and, thus, it could be represented as a fininte automata. In fact, the `SimpleMatcher` turns each of the patterns into a regular expression and then iteratively matches the path against those regular expressions. In other words, the `SimpleMatcher` executes the finite automata of each rule independently. The `AutomataMatcher`, on the other hand, combines all of the patterns into a single finite automata. For example, here is the state machine for Github's [exmaple CODEOWNERS](tests/CODEOWNERS.example).

[![Automata for CODEOWNERS.example](tests/CODEOWNERS.example.png)](tests/CODEOWNERS.example.png)

The image was rendered with the following command:

```
bin/render-nfa tests/CODEOWNERS.example | dot -Tpng -o tests/CODEOWNERS.example.png
```

Acknowledgements
----------------

[](#acknowledgements)

The code in `SimpleMatcher` that converts patterns to regular expressions owes a debt of gratitude to .

Author(s)
---------

[](#authors)

- [Kelly Norton](https://github.com/kellegous)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.8% 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 ~4 days

Total

3

Last Release

564d ago

Major Versions

0.1.0 → 1.0.02024-10-30

### Community

Maintainers

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

---

Top Contributors

[![kellegous](https://avatars.githubusercontent.com/u/54528?v=4)](https://github.com/kellegous "kellegous (43 commits)")[![stevegrunwell](https://avatars.githubusercontent.com/u/233836?v=4)](https://github.com/stevegrunwell "stevegrunwell (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kellegous-codeowners/health.svg)

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

###  Alternatives

[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k404.0M702](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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