/php-transpiler

:cactus: Transpiler API to convert php-parser AST to Javascript

Primary LanguageJavaScriptBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

php-transpiler

Transpiler API to convert php-parser AST to a Javascript output. This library is used to run a php script with :

  • PHP Runtime - the API compliant with PHP Transpiler output
  • Glayzzle - the nodejs CLI that runs PHP Files

npm version Build Status Coverage Status Gitter

Installation

This library is distributed with npm :

npm install php-transpiler --save

Usage

// initialize the php parser factory class
var transpiler = require('php-transpiler');
var instance = new transpiler({
  browser: true // says if we generate code for browser or nodejs
});

var jsCode = instance.read('<?php echo "Hello World";');
console.log(jsCode);

Will output :

module.exports = function($php) {
  $php.stdout.print ('hello world');
};

Misc

This library is released under BSD-3 license clause.