Registry / data / js-to-php-transpiler

js-to-php-transpiler

JSON →
library1.0.1jsnpmunverified

A simple transpiler that converts JavaScript code to PHP. Version 1.0.1 is the current stable release with no clear release cadence. It supports single file and directory transpilation, with an optional watch mode. This tool is explicitly marked as a fun experiment not intended for production use, differentiating it from serious transpilers like Babel or TypeScript compiler. It is primarily a CLI tool with no programmatic API documented, and it does not support most modern JavaScript features.

npm install js-to-php-transpiler
INSTALL
IMPORT
SIG · JS-TO-PHP-TRANSPIL
J
js-to-php-transpiler
datajavascriptv1.0.1
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.

cli (js2php)
npx js2php <source> <dest>
js2php <source> <dest> (without npx if globally installed)
CLI tool; no programmatic API. Use via npx or global install.
default export (package.json)
Not applicable; no programmatic API.
const transpiler = require('js-to-php-transpiler')
The package does not export any programmatic API for direct use. Only CLI is available.

Demonstrates transpiling a simple JavaScript file to PHP using the CLI tool.

echo 'const x = 1;' > src/app.js npx js2php src/app.js build/app.php cat build/app.php
js-to-php --version
Debug
Known issues
gotchaNot intended for production use. The package is a fun experiment and may produce incorrect or insecure PHP code.
fix
Do not use in production environments. Use established transpilers (e.g., Babel) for serious work.
affects: all
gotchaNo programmatic API is exported. The package can only be used as a CLI tool.
fix
If you need a programmatic API, fork the package or use another transpiler.
affects: all
gotchaOnly basic JavaScript constructs are supported. Advanced ES6+ features (classes, arrow functions, promises, etc.) may not transpile correctly.
fix
Test your JavaScript code thoroughly. Simplify complex constructs or avoid using modern JS features.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'js-to-php-transpiler'
Package not installed locally or globally.
fix
Run 'npm install -g js-to-php-transpiler' or use npx: 'npx js2php ...'
SyntaxError: Unexpected token
The JavaScript source contains unsupported syntax (e.g., arrow functions, async/await).
fix
Rewrite the code using only basic ES5 constructs; avoid modern JS features.
TypeError: source is not a string
Called the CLI without proper arguments.
fix
Usage: js2php <source> <dest>. Ensure both arguments are provided.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
js-to-php-transpiler — npm install js-to-php-transpiler · libregistry