Registry / serialization / beejs2php

beejs2php

JSON →
library0.2.4jsnpmunverified

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.

npm install beejs2php
INSTALL
IMPORT
SIG · BEEJS2PHP
B
beejs2php
serializationjavascriptv0.2.4
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.

js2php (default)
import js2php from 'js2php'
const js2php = require('js2php')
Package is ESM only; CommonJS require will not work.
transpile
import { transpile } from 'js2php'
const { transpile } = require('js2php')
Named export, not default. Use import syntax.
cli command
js2php input.js > output.php
js2php --output output.php input.js
CLI does not accept --output flag; output goes to stdout only.

Demonstrates transpiling a simple ES6 class into PHP using the transpile() function.

import { transpile } from 'js2php'; const jsCode = ` class Hello { say(msg) { console.log(msg); } } `; try { const phpCode = transpile(jsCode); console.log(phpCode); } catch (err) { console.error('Transpilation failed:', err.message); }
Debug
Known issues
breakingPackage is marked as 'experimental' and 'do not use' in its README.
fix
Do not use in production. Consider alternatives like Babel or custom converters.
affects: >=0.0.0
deprecatedNo updates since 0.2.4; project is effectively abandoned.
fix
Seek actively maintained transpilers or rewrite manually.
affects: >=0.0.0
gotchaTranspiler does not support full ES6; many features like Promises, generators, and modules are missing.
fix
Limit input JS to the subset of features listed in the README.
affects: >=0.0.0
gotchaCLI usage: output goes only to stdout; no --output or -o flag.
fix
Use shell redirection: js2php input.js > output.php
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'transpile' of undefined
Tried to require the default export with destructuring from CommonJS.
fix
Use import statement or require with .default: const js2php = require('js2php').default;
ReferenceError: require is not defined in ES module scope
Using require() in an ES module environment.
fix
Switch to import syntax as the package is ESM-only.
Error: Unsupported feature: async function
The transpiler does not support async/await or generators.
fix
Remove or rewrite async functions before transpilation.
Upgrade
Version history
0.2.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
2
Resources
beejs2php — npm install beejs2php · libregistry