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)12118.4k↑42.5%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 1mo 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

48

—

FairBetter than 95% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community24

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

582d 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.4k902.6M1.8k](/packages/nikic-php-parser)[doctrine/lexer

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

11.2k910.8M118](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.0k151.8M732](/packages/erusev-parsedown)[behat/gherkin

Gherkin DSL parser for PHP

1.1k176.3M97](/packages/behat-gherkin)[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)

PHPackages © 2026

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