Overview
php-parser
This javascript library parses PHP code and convert it to AST.
Installation
This library is distributed with npm :
Usage
Sample AST output
Try it online (demo) : http://glayzzle.com/php-parser/
Or from AST Explorer : https://astexplorer.net/
API Overview
The main API exposes a class with the following methods :
parseEval(String|Buffer) : parse a PHP code in eval style mode (without php open tags)
parseCode(String|Buffer, String filename) : parse a PHP code by using php open tags.
tokenGetAll(String|Buffer) : retrieves a list of all tokens from the specified input.
You can also pass options that change the behavior of the parser/lexer.
Documentation
Related projects
prettier/plugin-php : Prettier PHP Plugin
babel-preset-php : Babel preset for converting PHP syntax to JavaScript. It can run subset of PHP in the browser or in Node.js
wp-pot : Generate pot file for WordPress plugins and themes
crane : PHP Intellisense/code-completion for VS Code
php-unparser : Produce code that uses the style format recommended by PSR-1 and PSR-2.
php-writer : Update PHP scripts from their AST
ts-php-inspections : Provide PHP code inspections written in typescript
php-reflection : Reflection API for PHP files
vscode-phpunit : vscode phpunit extension
You can add here your own project by opening an issue request.
License
This library is released under BSD-3 license clause.
Last updated