Skip to content

NodeJSDevelopment/php-parser

Repository files navigation

php-parser

Parse PHP code from NodeJS and convert it to AST. This library is a standalone module of a larger project named Glayzzle.

npm version Build Status Coverage Status Gitter

Install it

$ npm install php-parser --save

Use it

// initialize a new parser instance
var parser = require('php-parser').create();

// how to retrieve the AST
var AST = parser.parseEval('echo "Hello World";');

// how to list tokens
var tokens = parser.tokenGetAll('<?php echo "Hello World";');

For more details please visit he wiki.

Output

[
  'program',  <-- program node
  [
    [ 'sys',  <-- first child, typed system call
      'echo', <-- operation echo
      [
        [ 'string', '"Hello World"' ]  <-- first argument
      ]
    ]
  ]
]

Try it online (demo) : http://glayzzle.com/php-parser/#demo

Contributing

If you want to contribute please visit this repository https://github.com/glayzzle/php-parser-dev.

Misc

This library is released under BSD-3 license clause.

About

🌿 NodeJS PHP Parser - extract AST or tokens (PHP5 and PHP7)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%