@expreva/php-parser

1.0.0 • Public • Published

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)

Known limitations

After using the PHP runtime instance, it is necessary to exit the process when done.

// Exit to stop PHP process
process.exit()

Abstract Syntax Tree

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

Included libraries

Readme

Keywords

none

Package Sidebar

Install

npm i @expreva/php-parser

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

905 kB

Total Files

270

Last publish

Collaborators

  • eliot