PHPackages                             smuuf/php-peg - 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. smuuf/php-peg

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

smuuf/php-peg
=============

PEG parser generator for PHP.

3.1.0(1y ago)13129.3k↓19.7%6[1 PRs](https://github.com/smuuf/php-peg/pulls)3MITPHPPHP &gt;=8.0

Since Nov 1Pushed 1y ago4 watchersCompare

[ Source](https://github.com/smuuf/php-peg)[ Packagist](https://packagist.org/packages/smuuf/php-peg)[ Docs](https://github.com/smuuf/php-peg)[ RSS](/packages/smuuf-php-peg/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (8)Dependencies (2)Versions (15)Used By (3)

PEG parser-generator for PHP
============================

[](#peg-parser-generator-for-php)

### Disclaimer

[](#disclaimer)

This is a *somehow opinionated* continuation of [combyna/php-peg](https://github.com/combyna/php-peg), which was "a minimally invasive fork" of the original [hafriedlander/php-peg](https://github.com/hafriedlander/php-peg).

From the several originally available types of PEG parsers only `Basic` and `Packrat` *(recommended)* remain now.

Notable features of this fork:
------------------------------

[](#notable-features-of-this-fork)

- **Fix, Optimization**: *Packrat parser overhaul.* Simplified logic using arrays instead of a string. Arrays ultimately seemed to be more fit for the job, *memory-wise*. This also fixed occasional problem with accessing undefined indexes in packrat cache.
- **Modern code style:** Codebase uses new *(PHP7+)* language features and code format more familiar to current modern PHP.
- **CLI interface is removed:** Just call `\hafriedlander\Peg\Compiler::compile($grammarDefinitionFile)` directly however you like.
- **Testing**: Test suite is rewritten to use [`Nette Tester`](https://github.com/nette/tester) instead of [PHPUnit](https://github.com/sebastianbergmann/phpunit).
- **Fixed**: Catastrophic backtracking problem *(sometimes happening when compiling a larger grammar)* avoided by simplifying regex that searches for grammar definitions.
- **Optimization**: Using native PHP constants and functions with absolute namespace is slightly faster *(changed in generated code, too)*.
- **Optimization**: Use strict comparisons where possible *(even in generated code)*.

Documentation
-------------

[](#documentation)

See the [documentation of the original library](https://github.com/hafriedlander/php-peg).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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 ~279 days

Recently: every ~413 days

Total

14

Last Release

674d ago

Major Versions

1.0.2 → 2.0.02017-03-03

2.2.3 → 3.0.02022-04-25

PHP version history (4 changes)1.0.0PHP &gt;=5.3.0

2.1PHP &gt;=7.0

3.0.0PHP &gt;=7.4

3.1.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6860713?v=4)[Přemysl Karbula](/maintainers/smuuf)[@smuuf](https://github.com/smuuf)

---

Top Contributors

[![smuuf](https://avatars.githubusercontent.com/u/6860713?v=4)](https://github.com/smuuf "smuuf (30 commits)")[![hnesk](https://avatars.githubusercontent.com/u/186821?v=4)](https://github.com/hnesk "hnesk (7 commits)")[![asmblah](https://avatars.githubusercontent.com/u/1714005?v=4)](https://github.com/asmblah "asmblah (3 commits)")[![peter-kolenic](https://avatars.githubusercontent.com/u/3885371?v=4)](https://github.com/peter-kolenic "peter-kolenic (3 commits)")[![djaf77](https://avatars.githubusercontent.com/u/8984222?v=4)](https://github.com/djaf77 "djaf77 (2 commits)")[![uwetews](https://avatars.githubusercontent.com/u/1246127?v=4)](https://github.com/uwetews "uwetews (1 commits)")[![simonwelsh](https://avatars.githubusercontent.com/u/125915?v=4)](https://github.com/simonwelsh "simonwelsh (1 commits)")[![cognifloyd](https://avatars.githubusercontent.com/u/1558590?v=4)](https://github.com/cognifloyd "cognifloyd (1 commits)")

---

Tags

parserDSLcompilerpeg

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/smuuf-php-peg/health.svg)

```
[![Health](https://phpackages.com/badges/smuuf-php-peg/health.svg)](https://phpackages.com/packages/smuuf-php-peg)
```

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k972.9M2.8k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k980.3M171](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.1k158.5M923](/packages/erusev-parsedown)[behat/gherkin

Gherkin DSL parser for PHP

1.1k187.8M157](/packages/behat-gherkin)[masterminds/html5

An HTML5 parser and serializer.

1.8k280.1M361](/packages/masterminds-html5)[matomo/device-detector

The Universal Device Detection library, that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, media players, mobile apps, feed readers, libraries, etc), operating systems, devices, brands and models.

3.5k27.7M213](/packages/matomo-device-detector)

PHPackages © 2026

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