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

mago-wasm

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

53 releases (20 breaking)

Uses new Rust 2024

new 0.20.1 Mar 14, 2025
0.19.5 Mar 11, 2025
0.0.18 Dec 29, 2024

#348 in WebAssembly

Download history 439/week @ 2024-12-05 257/week @ 2024-12-12 236/week @ 2024-12-19 298/week @ 2024-12-26 31/week @ 2025-01-02 143/week @ 2025-01-09 701/week @ 2025-01-16 486/week @ 2025-01-23 731/week @ 2025-01-30 344/week @ 2025-02-06 168/week @ 2025-02-13 372/week @ 2025-02-20 603/week @ 2025-02-27 963/week @ 2025-03-06

2,110 downloads per month

MIT/Apache

2MB
46K 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

~11–21MB
~291K SLoC