This release is 3 versions behind 0.5.0 — the latest version of @fmt/mago-fmt. Jump to latest
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Works with
•JSR Score100%•This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers




Downloads3/wk
•Published4 days ago (0.4.0)
A WASM based PHP Formatter
Install
npm install @wasm-fmt/mago_fmt
npx jsr add @fmt/mago-fmt
Usage
Node.js / Deno / Bun / Bundler
import { format } from "@wasm-fmt/mago_fmt"; const input = `<?php function hello( \$name ) { echo "Hello, " . \$name; } ?>`; const formatted = format(input, "main.php", { "use-tabs": false, "tab-width": 4, "print-width": 120, }); console.log(formatted);
With specific PHP version:
import { format_with_version } from "@wasm-fmt/mago_fmt"; const input = `<?php function hello( \$name ) { echo "Hello, " . \$name; } ?>`; const formatted = format_with_version(input, "8.3", "main.php", { "use-tabs": false, "tab-width": 4, "print-width": 120, }); console.log(formatted);
Web
For web environments, you need to initialize WASM module manually:
import init, { format } from "@wasm-fmt/mago_fmt/web"; await init(); const input = `<?php function hello( \$name ) { echo "Hello, " . \$name; } ?>`; const formatted = format(input, "main.php", { "use-tabs": false, "tab-width": 4, "print-width": 120, }); console.log(formatted);
Vite
import init, { format } from "@wasm-fmt/mago_fmt/vite"; await init(); // ...
Entry Points
.- Auto-detects environment (Node.js uses node, Webpack uses bundler, default is ESM)./node- Node.js environment (no init required)./esm- ESM environments like Deno (no init required)./bundler- Bundlers like Webpack (no init required)./web- Web browsers (requires manual init)./vite- Vite bundler (requires manual init)
Credits
Thanks to:
- The Mago project created by Carthage Software
Built and signed on
GitHub Actions
Add Package
deno add jsr:@fmt/mago-fmt
Import symbol
import * as mago_fmt from "@fmt/mago-fmt";
Import directly with a jsr specifier
import * as mago_fmt from "jsr:@fmt/mago-fmt";
Add Package
pnpm i jsr:@fmt/mago-fmt
pnpm dlx jsr add @fmt/mago-fmt
Import symbol
import * as mago_fmt from "@fmt/mago-fmt";
Add Package
yarn add jsr:@fmt/mago-fmt
yarn dlx jsr add @fmt/mago-fmt
Import symbol
import * as mago_fmt from "@fmt/mago-fmt";
Add Package
vlt install jsr:@fmt/mago-fmt
Import symbol
import * as mago_fmt from "@fmt/mago-fmt";
Add Package
npx jsr add @fmt/mago-fmt
Import symbol
import * as mago_fmt from "@fmt/mago-fmt";
Add Package
bunx jsr add @fmt/mago-fmt
Import symbol
import * as mago_fmt from "@fmt/mago-fmt";