1.1.0 • Published 7 months ago

@expreva/php-parser v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

PHP Parser

This is a standalone library to parse PHP in Node.js. It bundles a PHP runtime compiled to WebAssembly, so it doesn't depend on PHP being installed on the local system.

Install

npm install @expreva/php-parser

Usage

import { createPhp } from '@expreva/php-parser'

await php = await createPhp()

const code = `<?php echo 'hi';`

const {
  parsed, // Node[]
  error   // Error
} = await php.parse(code)

console.log(parsed)

Abstract Syntax Tree

See https://github.com/nikic/PHP-Parser/blob/master/doc/component/JSON_representation.markdown

Included libraries

1.1.0

7 months ago

1.0.0

2 years ago