mck89 / peast
Peast is PHP library that generates AST for JavaScript code
Installs: 17 704 755
Dependents: 21
Suggesters: 1
Security: 0
Stars: 176
Watchers: 10
Forks: 20
Open Issues: 0
Requires
- php: >=5.4.0
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- dev-master / 1.16.3.x-dev
- v1.16.3
- v1.16.2
- v1.16.1
- v1.16.0
- 1.15.x-dev
- v1.15.4
- v1.15.3
- v1.15.2
- v1.15.1
- v1.15.0
- 1.14.x-dev
- v1.14.0
- 1.13.x-dev
- v1.13.11
- v1.13.10
- v1.13.9
- v1.13.8
- v1.13.7
- v1.13.6
- v1.13.5
- v1.13.4
- v1.13.3
- v1.13.2
- v1.13.0
- 1.12.x-dev
- v1.12.0
- 1.11.x-dev
- v1.11.0
- 1.10.x-dev
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10
- 1.9.x-dev
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9
- 1.8.x-dev
- v1.8.1
- v1.8
- 1.7.x-dev
- v1.7
- 1.6.x-dev
- v1.6
- 1.5.x-dev
- v1.5
- 1.4.x-dev
- v1.4
- 1.3.x-dev
- v1.3
- 1.2.x-dev
- v1.2
- 1.1.x-dev
- v1.1
- 1.0.x-dev
- v1.0
- dev-php-8.4-compatibility
- dev-performance
This package is auto-updated.
Last update: 2024-11-23 14:43:45 UTC
README
Peast (PHP ECMAScript Abstract Syntax Tree) is a PHP 5.4+ library that parses JavaScript code, according to ECMAScript specification, and generates an abstract syntax tree following the ESTree standard.
Installation
Include the following requirement to your composer.json:
{ "require": { "mck89/peast": "dev-master" } }
Run composer install
to install the package.
Then in your script include the autoloader and you can start using Peast:
require_once "vendor/autoload.php"; $source = "var a = 1"; // Your JavaScript code $ast = Peast\Peast::latest($source, $options)->parse(); // Parse it!
Known issues
When Xdebug is enabled and Peast is used to scan code that contains deeply nested functions, this fatal error can appear:
PHP Fatal error: Maximum function nesting level of '512' reached, aborting!
or
PHP Warning: Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames
To prevent this you can set xdebug.max_nesting_level
to a higher value, such as 512.
Documentation
Read the documentation for more examples and explanations: