PHPRegex Documentation
You are browsing the source folder. The served documentation lives at php-regex.com — full-text search, a dark mode, and links that survive file renames.
PHPRegex parses a PCRE pattern into an AST and gives structured answers about validity, meaning, backtracking risk, capture shape, and equivalence. The documentation is organized by what you are trying to do.
Choose your path
Install and run
One package, five minutes to a first verdict on a pattern of your own.
Quick startLearn the toolchain
Regular expressions from zero, then the AST, visitors, and proofs on top.
TutorialPut it in your stack
Findings where you already work: PHPStan, Rector, Laravel, Symfony, your editor.
GuidesUnderstand a warning
Every diagnostic, what it means, and what stands behind it.
Lint rulesDeeper in, the same paths continue:
- Choose a package — the monorepo or the focused packages, per integration.
- Call the library from PHP — the API reference.
- Check what is proved or heuristic — the correctness contracts.
- Extend or embed the engine — architecture and internals.
- Lint a codebase from the terminal — the CLI guide.
Read findings correctly
PHPRegex separates three kinds of answers:
- Proven
- Follows from the parsed pattern itself, from a mathematical model built on it, or from running the pattern on the real PCRE engine.
- Heuristic
- The pattern uses a construct outside the proof model, or the analysis hit its budget, so conservative structural rules decided.
- Unknown
- Records that the analysis refuses to guess.
The correctness contracts define those boundaries feature by feature. Treat a ReDoS finding as a strong lead to investigate, not a substitute for reviewing the rewrite.
Documentation map
- Learn: tutorial, PHP regex guide, ReDoS guide, cookbook, troubleshooting.
- Integrations: CLI, PHPStan, Psalm, Rector, PHPUnit, Laravel, Symfony, language server.
- Concepts: AST, visitors, PCRE behavior, and ReDoS theory.
- Reference: diagnostics, API, output contracts, support matrices, compatibility.
- Internals: architecture, traversal, AST nodes, visitors, extending, adding a lint rule, maintainer guide.
Getting help
- Bugs and feature requests: GitHub issues.
- Design questions and usage discussion: GitHub discussions.
- Security reports follow the responsible disclosure policy.