{"id":27234,"library":"php-generator","title":"js2php","description":"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.","status":"deprecated","version":"0.3.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","php","transpiler","transcompiler"],"install":[{"cmd":"npm install php-generator","lang":"bash","label":"npm"},{"cmd":"yarn add php-generator","lang":"bash","label":"yarn"},{"cmd":"pnpm add php-generator","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is meant to be used as a CLI tool, not a library.","wrong":"npm install js2php --save-dev","symbol":"js2php (CLI)","correct":"npm install -g js2php"}],"quickstart":{"code":"// simple.js\nfunction add(a, b) {\n  return a + b;\n}\n\nclass Greeter {\n  constructor(name) {\n    this.name = name;\n  }\n  greet() {\n    return `Hello, ${this.name}!`;\n  }\n}\n\nconsole.log(add(1, 2));\nconsole.log(new Greeter('World').greet());","lang":"javascript","description":"Converts a JavaScript file with ES6 class and arrow function to PHP using the CLI tool."},"warnings":[{"fix":"Consider using alternative transpilers or rewriting code manually in PHP.","message":"This project is experimental and not recommended for production use. Use at your own risk.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Check the converted PHP output carefully and manually fix any missing or incorrect implementations.","message":"Core JavaScript APIs (e.g., Array functions, JSON) are only partially converted and may produce incorrect PHP code.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Do not use Date in JavaScript code intended for transpilation, or manually implement date handling in PHP.","message":"Date object support is explicitly missing (\"Date (missing)\" in README).","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install globally: npm install -g js2php","cause":"js2php is not installed globally or not in PATH.","error":"js2php: command not found"},{"fix":"Reinstall the package: npm install -g js2php","cause":"Dependencies missing or broken installation.","error":"Error: Cannot find module '...'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}