PHPackages                             syntaxx/phpx-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. syntaxx/phpx-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

syntaxx/phpx-parser
===================

A PHPX parser written in PHP

v5.4.2(6mo ago)0211BSD-3-ClausePHPPHP &gt;=7.4

Since Apr 7Pushed 6mo agoCompare

[ Source](https://github.com/kambo-1st/PHP-X-Parser)[ Packagist](https://packagist.org/packages/syntaxx/phpx-parser)[ RSS](/packages/syntaxx-phpx-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (1)

PHPX Parser
===========

[](#phpx-parser)

[![Coverage Status](https://camo.githubusercontent.com/5c74b7d687daeb9de09aaf1d94fbaf57286d372dd1aed827759f09ce44082914/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e696b69632f5048502d5061727365722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/nikic/PHP-Parser?branch=master)

This is PHPX, a fork of PHP-Parser with added support for JSX syntax. It extends the original PHP parser to support static code analysis and manipulation of both PHP and JSX code.

[**Documentation for version 5.x**](https://github.com/kambo/PHP-X-Parser/tree/master/doc) (current; for running on PHP &gt;= 7.4; for parsing PHP 7.0 to PHP 8.4, with limited support for parsing PHP 5.x).

[Documentation for version 4.x](https://github.com/kambo/PHP-X-Parser/tree/4.x/doc) (supported; for running on PHP &gt;= 7.0; for parsing PHP 5.2 to PHP 8.3).

Features
--------

[](#features)

The main features provided by this library are:

- Parsing PHP 7, PHP 8, and JSX code into an abstract syntax tree (AST).
    - Invalid code can be parsed into a partial AST.
    - The AST contains accurate location information.
    - Full support for JSX syntax and components.
- Dumping the AST in human-readable form.
- Converting an AST back to PHP/JSX code.
    - Formatting can be preserved for partially changed ASTs.
- Infrastructure to traverse and modify ASTs.
- Resolution of namespaced names.
- Evaluation of constant expressions.
- Builders to simplify AST construction for code generation.
- Converting an AST into JSON and back.

Quick Start
-----------

[](#quick-start)

Install the library using [composer](https://getcomposer.org):

```
php composer.phar require kambo/php-x-parser

```

Parse some PHP/JSX code into an AST and dump the result in human-readable form:

```
