Analysis updated 2026-06-24
Build a static analyzer that flags unused functions in a PHP codebase
Write a refactor script that renames a class everywhere it is used
Generate PHP files from a template by constructing AST nodes programmatically
Serialize PHP code to JSON for inspection from another language
| nikic/php-parser | koel/koel | bcit-ci/codeigniter | |
|---|---|---|---|
| Stars | 17,430 | 17,135 | 18,185 |
| Language | PHP | PHP | PHP |
| Setup difficulty | easy | moderate | easy |
| Complexity | 3/5 | 3/5 | 3/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Needs PHP 7.4 or later on the host running the parser, even though it can parse older PHP code.
PHP-Parser is a PHP library that can read and analyze PHP source code as structured data. It takes a PHP file or code string and converts it into an AST (Abstract Syntax Tree, a structured, tree-shaped representation of the code that's easy for programs to work with). This is the foundation for tools that inspect, transform, or generate PHP code programmatically. The library is written in PHP itself, which means it runs inside any PHP project without external dependencies. You install it via Composer (PHP's package manager) and use it to parse PHP 7 and PHP 8 code into an AST, traverse and modify that AST using visitor classes, convert the modified AST back to PHP source code (including options to preserve original formatting), evaluate constant expressions, resolve namespaces, and serialize the AST to JSON. The quickstart example in the README shows exactly how this works: you write a parser, call parse() on a PHP code string, get back an AST object, walk through it to make changes (the example removes all function bodies), then print the modified AST back out as valid PHP code. This kind of tool is used when building static analysis tools (programs that inspect code for errors or patterns without running it), code formatters, refactoring tools, code generators, or IDEs that need to understand code structure. The library supports PHP 7.0 through PHP 8.4 for parsing, and requires PHP 7.4 or higher to run the current version (5.x).
PHP library that parses PHP 7 and 8 source code into an Abstract Syntax Tree, lets you transform it with visitors, and prints it back as PHP.
Mainly PHP. The stack also includes PHP, Composer.
Setup difficulty is rated easy, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.