# PHP-Parser

> A PHP parser written in PHP, for static analysis and code changes

Source: https://talira.ai/catalog/php-parser-dnzq9cq0
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [developer tools / parsing / source code](https://talira.ai/categories/developer-tools/parsing/source-code), [languages / php](https://talira.ai/categories/languages/php)
- Licence: BSD-3-Clause[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [Nikita Popov](https://talira.ai/orgs/nikita-popov.md)

PHP-Parser is a parser for PHP code written in PHP, made to simplify static analysis and code manipulation. It parses PHP 7 and PHP 8 code into an abstract syntax tree with accurate locations, even partial trees from invalid code, and can dump the tree, turn it back into PHP while keeping the formatting of unchanged parts, and convert it to JSON and back. It has visitors to traverse and modify trees, name resolution, constant expression evaluation and builders for generating code.

## Links

- GitHub: https://github.com/nikic/PHP-Parser
- Docs: https://github.com/nikic/PHP-Parser/tree/master/doc

## Problems it solves

- parse PHP source code into an AST from a PHP script
- write a codemod that rewrites PHP code but keeps the original formatting
- build a static analysis check for a PHP codebase

## Features

- parses PHP 7 and PHP 8 into an AST
- partial ASTs from invalid code
- turns an AST back into PHP, keeping unchanged formatting
- visitors to traverse and modify ASTs
- namespaced name resolution
- builders for code generation
- AST to JSON and back

## Limitations

- Parsing of PHP 5.x code is limited in version 5.[^1]

## Trust

Overall: 0.61 out of 1.
Signals: maintenance 0.71, adoption 0.85, momentum 0.60, community 0.88, backing 0.30, extensibility 0.00.

- last commit 3 days ago
- 16 commits in the last 90 days
- latest release v5.9.0 2 months ago
- 17.5k GitHub stars
- 162 contributors
- backed by Nikita Popov

## Sources

[^1]: https://github.com/nikic/PHP-Parser/blob/master/README.md (checked 28 Nov 2026)
