{"id":25803,"library":"js2php","title":"js2php","description":"js2php is an experimental JavaScript to PHP source-to-source transpiler (version 0.1.7). It converts ES6 features like classes, arrow functions, template strings, and many core JavaScript prototypes (Array, JSON, Math, etc.) into PHP. The project is clearly marked as experimental and not recommended for production use. It is published on npm and has an online demo. There is no active development or maintenance; it is effectively abandoned.","status":"abandoned","version":"0.1.7","language":"javascript","source_language":"en","source_url":"https://github.com/endel/js2php","tags":["javascript","php","transpiler","transcompiler"],"install":[{"cmd":"npm install js2php","lang":"bash","label":"npm"},{"cmd":"yarn add js2php","lang":"bash","label":"yarn"},{"cmd":"pnpm add js2php","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only? Actually no, it's CommonJS. But this is a hypothetical import; the package does not export a `compile` function. It is a CLI tool mainly.","wrong":"const compile = require('js2php').compile","symbol":"compile","correct":"import { compile } from 'js2php'"},{"note":"The package is primarily used as a CLI tool. There is no documented programmatic API.","wrong":"const js2php = require('js2php')","symbol":"default (CLI)","correct":"npx js2php input.js > output.php"}],"quickstart":{"code":"// Install globally\nnpm install -g js2php\n\n# Create a simple test file\necho 'const add = (a, b) => a + b; console.log(add(1, 2));' > test.js\n\n# Transpile and run directly\njs2php test.js | php\n","lang":"javascript","description":"Shows CLI installation and basic usage: converting a JavaScript arrow function to PHP."},"warnings":[{"fix":"Do not use in production. Consider alternatives like ReactPHP or writing PHP directly.","message":"Package is experimental and explicitly says 'Please do not use it.'","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Do not rely on it. There is no active maintenance.","message":"No updates since 2017? The project is effectively abandoned.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Test your code thoroughly. Many JavaScript constructs will not transpile.","message":"Does not support full JavaScript; only a subset of ES6 features and core functions.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Rewrite the code to use supported features only, or use a different transpiler.","cause":"js2php does not support all ES6 syntax (e.g., destructuring, spread operator).","error":"SyntaxError: Unexpected token"},{"fix":"Do not use require() in the source JavaScript; write code that does not depend on Node.js APIs.","cause":"js2php transpiles to PHP and does not emulate Node.js modules.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}