Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. PHP
  3. PHP Parser

PHP Parser

BSD-3-ClausePHPv5.8.0

A PHP parser written in PHP for static code analysis and manipulation via an abstract syntax tree (AST).

GitHubGitHub
17.5k stars1.1k forks0 contributors

What is PHP Parser?

PHP-Parser is a library written in PHP that parses PHP source code into an abstract syntax tree (AST). It enables developers to programmatically analyze, traverse, and manipulate PHP code for tasks like static analysis, refactoring, and custom tooling. The tool supports modern PHP versions and handles invalid code gracefully with partial ASTs.

Target Audience

PHP developers building static analysis tools, code refactoring utilities, linters, or any application requiring programmatic inspection or modification of PHP source code.

Value Proposition

Developers choose PHP-Parser for its accuracy, comprehensive feature set, and active maintenance. It provides a reliable foundation for code manipulation with support for modern PHP versions, name resolution, and AST-to-code conversion, all within a pure PHP environment.

Overview

A PHP parser written in PHP

Use Cases

Best For

  • Building custom static analysis tools for PHP codebases
  • Creating automated code refactoring or migration scripts
  • Developing linters or coding standard enforcement utilities
  • Generating PHP code programmatically via AST builders
  • Implementing custom IDE features or code intelligence tools
  • Analyzing code structure for documentation or visualization purposes

Not Ideal For

  • Projects requiring only basic code formatting or linting without custom analysis
  • Teams seeking out-of-the-box refactoring tools without development overhead
  • Applications needing real-time, lightweight syntax checking in web interfaces
  • Developers extensively working with legacy PHP 5.2 code requiring full parsing accuracy

Pros & Cons

Pros

Accurate Modern Parsing

Supports PHP 7.0 to 8.4 with precise location information and can parse invalid code into partial ASTs, as highlighted in the features list.

Flexible AST Manipulation

Provides traversal infrastructure and node visitors for easy code modifications, demonstrated in the quick start example for stripping function bodies.

Format-Preserving Generation

Converts ASTs back to PHP code while maintaining original formatting for unmodified parts, enabling incremental changes without style disruption.

Built-in Name Resolution

Resolves namespaced names within the AST, essential for accurate static analysis without runtime execution, as documented in the components.

Cons

Steep Learning Curve

Requires deep understanding of AST structures and node types, making it inaccessible for developers needing simple, quick solutions.

Performance Overheads

Parsing and traversing large codebases can be resource-intensive, with documentation advising optimizations like disabling Xdebug.

Version Fragmentation

Maintains multiple active branches (e.g., 4.x and 5.x) with differing PHP version support, which can confuse users about compatibility.

Frequently Asked Questions

Quick Stats

Stars17,452
Forks1,129
Contributors0
Open Issues49
Last commit12 days ago
CreatedSince 2011

Tags

#php#development-tools#ast#refactoring#abstract-syntax-tree#code-generation#parser#static-analysis

Built With

P
PHP

Included in

PHP32.5kStatic Analysis & Code Quality14.5k
Auto-fetched 3 hours ago

Related Projects

TypeScript ESLintTypeScript ESLint

:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript

Stars16,320
Forks2,952
Last commit21 hours ago
pyrightpyright

Static Type Checker for Python

Stars15,545
Forks1,797
Last commit2 days ago
RectorRector

Instant Upgrades and Automated Refactoring of any PHP 5.3+ code

Stars10,379
Forks740
Last commit9 hours ago
ReviewdogReviewdog

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

Stars9,474
Forks490
Last commit5 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub