#mago #php #analysis #format #wasm-module #linter #formatter

mago-wasm

Exposes PHP code analysis and tooling functionalities as WebAssembly modules, enabling browser-based tools and editor integrations

34 releases (9 breaking)

new 0.9.1 Feb 8, 2025
0.8.1 Feb 2, 2025
0.0.18 Dec 29, 2024

#199 in WebAssembly

Download history 63/week @ 2024-12-02 576/week @ 2024-12-09 117/week @ 2024-12-16 334/week @ 2024-12-23 162/week @ 2024-12-30 141/week @ 2025-01-06 526/week @ 2025-01-13 194/week @ 2025-01-20 1069/week @ 2025-01-27 458/week @ 2025-02-03

2,254 downloads per month

MIT/Apache

2MB
42K SLoC

Mago WASM

mago-wasm is a WebAssembly (WASM) crate designed to provide high-level functionality for the Mago toolchain, specifically tailored for use in browser environments. This crate is primarily intended for the Mago Playground and similar projects where running Mago directly in the browser is required.

If you are building applications outside of a browser context, you should use the dedicated Mago crates instead of this crate.

Building

To build the WASM module, run the following command:

wasm-pack build --target web

This will generate a pkg directory containing the WASM module and associated JavaScript bindings.


lib.rs:

Mago WASM Bindings

This crate provides [wasm-bindgen] exports that wrap Mago’s internal functionality (formatter, parser, linter, etc.) so they can be called from JavaScript in a WebAssembly environment.

Overview

  • mago_get_definitions: Returns metadata about all available plugins and rules in Mago.
  • mago_analysis: Parses, lints, and optionally formats a given PHP snippet and returns structured results.
  • mago_format: Formats a given PHP snippet according to the specified [FormatSettings].

See each function’s documentation below for details on usage and return values.

Dependencies

~10–20MB
~282K SLoC