// initialize the php parser factory class
var path = require('path');
var engine = require('php-parser');
// initialize a new parser instance
var parser = new engine({
// Retrieve the AST from the specified source
var eval = parser.parseEval('echo "Hello World";');
// Retrieve an array of tokens (same as php function token_get_all)
var tokens = parser.tokenGetAll('<?php echo "Hello World";');
// Load a static file (Note: this file should exist on your computer)
var phpFile = fs.readFileSync( './example.php' );
console.log( 'Eval parse:', eval );
console.log( 'Tokens parse:', tokens );
console.log( 'File parse:', parser.parseCode(phpFile) );