VS Code extension for the mago PHP toolchain — formatting, linting, and static analysis.
From the VS Code Marketplace (recommended):
- Open VS Code
- Press
⌃⇧X(⌘⇧Xon MacOS) to open Extensions - Search for "Mago PHP Toolchain"
- Click Install
Or install directly from the command line:
code --install-extension kellymears.vscode-mago- Format — Format PHP files using
mago format(format-on-save compatible) - Lint — Real-time diagnostics from 135+ lint rules across 9 categories
- Analyze — Static analysis diagnostics in the Problems panel
- Code actions — Quick fixes and batch fix-all from mago suggestions
- Explain rule — View documentation for any lint rule from the command palette
Install the mago CLI. The extension searches for the binary in this order:
mago.binsetting (explicit path)./vendor/bin/mago(Composer local)./mago(workspace root)- System
$PATH
| Setting | Default | Description |
|---|---|---|
mago.enabled |
true |
Master enable/disable |
mago.bin |
"" |
Custom binary path |
mago.configPath |
"" |
Custom mago.toml path |
mago.phpVersion |
"" |
Override PHP version |
mago.lint.enabled |
false |
Enable lint diagnostics |
mago.lint.run |
"onSave" |
"onSave" or "onType" |
mago.analyze.enabled |
false |
Enable analyzer diagnostics |
mago.format.enabled |
true |
Register as formatter |
mago.trace.level |
"info" |
Log verbosity (off/error/warn/info/debug) |
All commands are available via the Command Palette (⌃⇧P / ⌘⇧P):
- Mago: Format File — Format the active PHP file
- Mago: Lint File — Lint the active file
- Mago: Lint Workspace — Lint all files in the workspace
- Mago: Analyze File — Run static analysis on the active file
- Mago: Analyze Workspace — Analyze all workspace files
- Mago: Fix File (Safe) — Apply safe auto-fixes
- Mago: Fix File (All Including Unsafe) — Apply all fixes (with confirmation)
- Mago: Explain Rule — Show documentation for a lint rule
- Mago: Show Output — Open the output channel
- Mago: Restart — Re-resolve binary and refresh diagnostics