#mago #linter #mago-wasm

mago-wasm

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

60 releases (22 breaking)

Uses new Rust 2024

new 0.23.0 Apr 13, 2025
0.22.1 Mar 26, 2025
0.0.18 Dec 29, 2024

#461 in WebAssembly

Download history 243/week @ 2024-12-21 297/week @ 2024-12-28 135/week @ 2025-01-04 285/week @ 2025-01-11 449/week @ 2025-01-18 787/week @ 2025-01-25 594/week @ 2025-02-01 186/week @ 2025-02-08 216/week @ 2025-02-15 451/week @ 2025-02-22 609/week @ 2025-03-01 1094/week @ 2025-03-08 541/week @ 2025-03-15 278/week @ 2025-03-22 30/week @ 2025-03-29 124/week @ 2025-04-05

1,100 downloads per month

MIT/Apache

2.5MB
52K SLoC

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.


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.

Dependencies

~11–21MB
~286K SLoC