Glayzzle
raw JSON → 0.3.0 verified Fri May 01 auth: no javascript abandoned
Glayzzle is a PHP-to-JavaScript transpiler and CLI that allows running PHP scripts using Node.js or in the browser. As of version 0.3.0 (released circa 2016), it is a proof-of-concept with limited functionality: basic PHP syntax transpilation, file execution via CLI, and a simple server mode using Node.js cluster. It does not support many PHP features like PDO, dynamic variable names, or full function libraries. The project appears to be pre-alpha and is not suitable for production use. Differentiators: transpiles PHP to JS using generators/promises for async I/O, targets Node.js ecosystem.
Common errors
error Cannot find module 'php-parser' ↓
cause Missing dependency php-parser not installed automatically.
fix
npm install php-parser
error TypeError: glayzzle.Glayzzle is not a constructor ↓
cause Incorrect import pattern; used default import instead of named import.
fix
const { Glayzzle } = require('glayzzle')
error Error: PHP syntax error: unexpected token ↓
cause Glayzzle does not support full PHP syntax, e.g., short array syntax [], closures, etc.
fix
Simplify PHP code or use alternative transpiler.
error bash: glz: command not found ↓
cause glz is not in PATH or not installed globally.
fix
Run npx glz instead of glz, or install globally with npm install -g glayzzle
Warnings
gotcha Package is proof-of-concept; most PHP features not supported (PDO, mysql, dynamic variables). ↓
fix Do not use for production. Check feature list before using.
deprecated Last version 0.3.0 from 2016; no updates or maintenance. ↓
fix Look for alternatives like phpto.js or use php-wasm in browser.
breaking CLI may not work on Windows due to unix-style paths and dependencies. ↓
fix Use WSL or Docker on Windows.
gotcha Asynchronous transpilation uses promises; synchronous PHP code blocks Node event loop. ↓
fix Use promises and avoid blocking I/O patterns.
breaking No PHP library support; built-in functions like array_merge are not implemented. ↓
fix Rewrite PHP logic in JavaScript or use polyfills.
Install
npm install glayzzle yarn add glayzzle pnpm add glayzzle Imports
- glayzzle wrong
import glayzzle from 'glayzzle'correctconst glayzzle = require('glayzzle') - cli wrong
glz -r "echo 'hello';"correctnpx glz -r 'echo "hello";' - Glayzzle API wrong
const g = new Glayzzle()correctconst Glayzzle = require('glayzzle').Glayzzle; const g = new Glayzzle()
Quickstart
const glayzzle = require('glayzzle');
const glz = new glayzzle.Glayzzle();
// Transpile a simple PHP snippet
glz.eval('echo "Hello from PHP!";').then(output => {
console.log(output);
}).catch(err => {
console.error(err);
});