loophp / phptree-ast-generator
Generates AST of a PHP script in DOT (Graphviz) or Image (PNG, JPG, SVG) formats.
Fund package maintenance!
drupol
Requires
- php: >= 7.1
- loophp/phptree: ^2.6.2
- nikic/php-parser: ^4.3.0
- symfony/console: ^4 || ^5
Requires (Dev)
- drupol/php-conventions: ^1.6.14
- friends-of-phpspec/phpspec-code-coverage: ^4.3.2
- infection/infection: ^0.13.6 || ^0.15.3
- microsoft/tolerant-php-parser: ^0.0.20
- phpspec/phpspec: ^5.1.2 || ^6.1.1
This package is auto-updated.
Last update: 2024-12-09 14:55:19 UTC
README
PHPTree AST Generator
Description
An AST generator based on loophp/phptree.
Requirements
- PHP >= 7.1
- A PHP Parser:
Installation
composer require loophp/phptree-ast-generator
Usage
Very basic usage
./path/to/bin/ast generate /path/to/php/file.php
To generate the dot
script for Graphviz
./path/to/bin/ast generate src/Command/Generator.php
Use the -c
option to generate a fancy export, user-friendly and less verbose.
./path/to/bin/ast generate -c src/Command/Generator.php
To generate an image
./path/to/bin/ast generate -c -t image -f png -d graph.png src/Command/Generator.php
The generator supports 3 PHP parsers:
Use the -p
option to change it, default is nikic
.
./path/to/bin/ast generate -p microsoft -t image -d graph.svg src/Command/Generator.php
You will find more documentation within the help of the command:
./path/to/bin/ast generate -h
Contributing
Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)