Rust PHP Parser
A fast, fault-tolerant PHP parser written in Rust. Produces a full AST with source spans, recovers from syntax errors, and covers the vast majority of PHP 8.x syntax.
Inspired by and tested against the nikic/PHP-Parser test suite.
Note: The parser targets PHP 8.5 by default — all supported syntax from PHP 5.x through 8.5 is accepted.
Architecture
Cargo workspace with three crates:
Usage
use parse;
let result = parse;
println!;
for err in &result.errors
Performance
This parser is optimized for modern PHP applications with full typing (PHP 7.4+, 8.x). It delivers fastest performance on Symfony, Laravel, and other typed codebases.
The parser prioritizes performance on contemporary PHP patterns:
- Type hints — Full coverage (union types, mixed, never, readonly, attributes, etc.)
- Complex expressions — Method chains, array access, spread operators
- Arrays & collections — Configuration-heavy code (Symfony/Laravel patterns)
- Structured OOP — Classes, traits, interfaces with complete feature support
See PERFORMANCE_ANALYSIS.md and SYMFONY_OPTIMIZATION_ANALYSIS.md for detailed profiling and optimization analysis.
The fastest full-featured PHP parser. For comparative benchmarks against other PHP parsers (nikic/PHP-Parser, alternative implementations), see php-parser-benchmark.
Testing
Fixture files live in crates/php-parser/tests/fixtures/.
Roadmap
See ROADMAP.md.
License
BSD 3-Clause