Registry / php-generator

php-generator

JSON →
library0.3.2jsnpmunverified

Experimental JavaScript to PHP source-to-source transpiler (v0.3.2). Converts ES6 features (classes, arrow functions, template strings) and core JavaScript APIs (Array, JSON, Math, Number, String, Function) to PHP code, with partial Date support. The project is marked as experimental and not for production use. No active maintenance or recent releases.

npm install php-generator
INSTALL
IMPORT
SIG · PHP-GENERATOR
P
php-generator
javascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

js2php (CLI)
npm install -g js2php
npm install js2php --save-dev
The package is meant to be used as a CLI tool, not a library.

Converts a JavaScript file with ES6 class and arrow function to PHP using the CLI tool.

// simple.js function add(a, b) { return a + b; } class Greeter { constructor(name) { this.name = name; } greet() { return `Hello, ${this.name}!`; } } console.log(add(1, 2)); console.log(new Greeter('World').greet());
Debug
Known issues
deprecatedThis project is experimental and not recommended for production use. Use at your own risk.
fix
Consider using alternative transpilers or rewriting code manually in PHP.
affects: >=0.1.0
gotchaCore JavaScript APIs (e.g., Array functions, JSON) are only partially converted and may produce incorrect PHP code.
fix
Check the converted PHP output carefully and manually fix any missing or incorrect implementations.
affects: >=0.1.0
breakingDate object support is explicitly missing ("Date (missing)" in README).
fix
Do not use Date in JavaScript code intended for transpilation, or manually implement date handling in PHP.
affects: >=0.1.0
Errors
Common errors & fixes
js2php: command not found
js2php is not installed globally or not in PATH.
fix
Install globally: npm install -g js2php
Error: Cannot find module '...'
Dependencies missing or broken installation.
fix
Reinstall the package: npm install -g js2php
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
php-generator — npm install php-generator · libregistry