endel / js2php

JavaScript (ES6) to PHP source-to-source transpiler.
https://endel.github.io/js2php/
MIT License
333 stars 41 forks source link
javascript php transpiler

js2php

Build status

JavaScript to PHP source-to-source transpiler. Online demo

This is an experiment. Please do not use it.

Installation

Usage

Convert a single JavaScript file into PHP:

js2php examples/simple.js > simple.php

Since js2php outputs the PHP code to stdout, you may run it right after conversion:

js2php examples/class.js | php

Features

What does it converts?

Testing

Tests are simple input (js) / output (php) comparisions.

  1. Create your source .js file at test/fixtures/js_feature.js
  2. Convert your .js to .php manually: node test/generate.js js_feature.js
  3. Run npm test

License

MIT