wikimedia/wikipeg
Wikipeg is a PHP port of PEG.js, the parser generator for parsing expression grammars. Write a grammar and it compiles it into a fast, standalone PHP parser with no runtime dependencies, making custom language and syntax parsers easy to build and maintain in PHP projects.
.pegjs grammar, it compiles to a plain PHP parser class, no Node/JS runtime in production. That's a genuine differentiator over PEG.js/Peggy, which would force a JS toolchain into a PHP deploy.ParserService yourself. Don't let it into a "Laravel packages we standardize on" list.Adopt when:
explode() have already failed once..pegjs file and the generated PHP alongside your app and regenerate deliberately.Look elsewhere when:
nikic/php-parser.symfony/expression-language; it's better supported and reviewers already know it.doctrine/lexer or plain regex.For executives (one paragraph): We have a recurring class of requests that need a small custom language — a filter syntax, a rules editor, an import format. Today each one becomes bespoke parser code that's expensive to change and hard to test. WikiPEG lets us describe the language as a readable grammar file and generate the PHP parser, so changes become grammar edits instead of rewrites. It's MIT-licensed and PHP-only at runtime. The trade-off is that it's a low-profile Wikimedia library with a thin external community, so we'd pin a version and treat the grammar as first-class internal code. Recommendation: prototype on one feature before standardizing.
For engineering (the honest version): It's a PHP port of PEG.js — write .pegjs, run the CLI, get a PHP class with parse(). No JS in the deploy pipeline, which is the whole reason to prefer it over Peggy. Caveats: development happens on Wikimedia Gerrit, not GitHub; expect to fork or vendor rather than get upstream PRs merged; generated code is committed and reviewed like any other source. Wrap it behind a domain interface so we can swap to a hand-written Pratt parser if the grammar stays small. Start with a spike on the smallest real grammar we have, with a test suite driven by grammar fixtures — if the spike is clean, the second and third languages are nearly free.
How can I help you explore Laravel packages today?