A transpiler that converts PHP AST (from php-parser) into JavaScript code. Version 0.4.0 is the latest stable release. The package is mature but sees infrequent updates. It differentiates by targeting the php-parser AST format, enabling automated PHP-to-JS conversion for server-side rendering or migration. Supports conversion of control structures, function calls, and basic output.
npm install php-transpilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates transpiling PHP code to JavaScript using php-parser for parsing and php-transpiler for generation.
Ensure consuming code expects a function that receives a $php context object.
Monitor changelog and use named imports.
Provide a $php polyfill when executing the generated code.
Review supported features in documentation before use.
Wrap generated code in a context: var $php = { stdout: { print: console.log } };Run 'npm install php-parser' alongside php-transpiler.