{"id":25799,"library":"js-to-php-transpiler","title":"JS to PHP Transpiler","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","js-to-php","react","ssr"],"install":[{"cmd":"npm install js-to-php-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add js-to-php-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-to-php-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CLI tool; no programmatic API. Use via npx or global install.","wrong":"js2php <source> <dest> (without npx if globally installed)","symbol":"cli (js2php)","correct":"npx js2php <source> <dest>"},{"note":"The package does not export any programmatic API for direct use. Only CLI is available.","wrong":"const transpiler = require('js-to-php-transpiler')","symbol":"default export (package.json)","correct":"Not applicable; no programmatic API."}],"quickstart":{"code":"echo 'const x = 1;' > src/app.js\nnpx js2php src/app.js build/app.php\ncat build/app.php","lang":"javascript","description":"Demonstrates transpiling a simple JavaScript file to PHP using the CLI tool."},"warnings":[{"fix":"Do not use in production environments. Use established transpilers (e.g., Babel) for serious work.","message":"Not intended for production use. The package is a fun experiment and may produce incorrect or insecure PHP code.","severity":"gotcha","affected_versions":"all"},{"fix":"If you need a programmatic API, fork the package or use another transpiler.","message":"No programmatic API is exported. The package can only be used as a CLI tool.","severity":"gotcha","affected_versions":"all"},{"fix":"Test your JavaScript code thoroughly. Simplify complex constructs or avoid using modern JS features.","message":"Only basic JavaScript constructs are supported. Advanced ES6+ features (classes, arrow functions, promises, etc.) may not transpile correctly.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install -g js-to-php-transpiler' or use npx: 'npx js2php ...'","cause":"Package not installed locally or globally.","error":"Error: Cannot find module 'js-to-php-transpiler'"},{"fix":"Rewrite the code using only basic ES5 constructs; avoid modern JS features.","cause":"The JavaScript source contains unsupported syntax (e.g., arrow functions, async/await).","error":"SyntaxError: Unexpected token"},{"fix":"Usage: js2php <source> <dest>. Ensure both arguments are provided.","cause":"Called the CLI without proper arguments.","error":"TypeError: source is not a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}