{"id":24989,"library":"beejs2php","title":"js2php","description":"Experimental JavaScript-to-PHP source-to-source transpiler (v0.2.4). Converts ES6 classes, arrow functions, template strings, loops, and core JS built-ins (Array, JSON, Math, Number, String, Function, Date) to PHP. Released as an experiment with no stable version cadence. Unlike full-featured transpilers like Babel, this is a proof-of-concept not intended for production use. The README explicitly advises against using it.","status":"deprecated","version":"0.2.4","language":"javascript","source_language":"en","source_url":"https://github.com/endel/js2php","tags":["javascript","php","transpiler","transcompiler"],"install":[{"cmd":"npm install beejs2php","lang":"bash","label":"npm"},{"cmd":"yarn add beejs2php","lang":"bash","label":"yarn"},{"cmd":"pnpm add beejs2php","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM only; CommonJS require will not work.","wrong":"const js2php = require('js2php')","symbol":"js2php (default)","correct":"import js2php from 'js2php'"},{"note":"Named export, not default. Use import syntax.","wrong":"const { transpile } = require('js2php')","symbol":"transpile","correct":"import { transpile } from 'js2php'"},{"note":"CLI does not accept --output flag; output goes to stdout only.","wrong":"js2php --output output.php input.js","symbol":"cli command","correct":"js2php input.js > output.php"}],"quickstart":{"code":"import { transpile } from 'js2php';\n\nconst jsCode = `\nclass Hello {\n  say(msg) {\n    console.log(msg);\n  }\n}\n`;\n\ntry {\n  const phpCode = transpile(jsCode);\n  console.log(phpCode);\n} catch (err) {\n  console.error('Transpilation failed:', err.message);\n}","lang":"typescript","description":"Demonstrates transpiling a simple ES6 class into PHP using the transpile() function."},"warnings":[{"fix":"Do not use in production. Consider alternatives like Babel or custom converters.","message":"Package is marked as 'experimental' and 'do not use' in its README.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Seek actively maintained transpilers or rewrite manually.","message":"No updates since 0.2.4; project is effectively abandoned.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Limit input JS to the subset of features listed in the README.","message":"Transpiler does not support full ES6; many features like Promises, generators, and modules are missing.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use shell redirection: js2php input.js > output.php","message":"CLI usage: output goes only to stdout; no --output or -o flag.","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":"Use import statement or require with .default: const js2php = require('js2php').default;","cause":"Tried to require the default export with destructuring from CommonJS.","error":"TypeError: Cannot read property 'transpile' of undefined"},{"fix":"Switch to import syntax as the package is ESM-only.","cause":"Using require() in an ES module environment.","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Remove or rewrite async functions before transpilation.","cause":"The transpiler does not support async/await or generators.","error":"Error: Unsupported feature: async function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}