
Mago — the Rust-powered PHP linter and formatter that sets up in 5 minutes
Mago (v1.29.0) is a single Rust binary that replaces PHP-CS-Fixer, PHPStan, and PHP_CodeSniffer for PHP projects — formatting WordPress (7M lines) in 0.43 seconds vs PHP-CS-Fixer's 25.3 seconds. The official VS Code extension `Clearlyip.mago-vscode-extension` v0.9.5 connects via a persistent LSP server rather than spawning a CLI process on each save, enabling real-time diagnostics and format-on-save. Covers 4-step setup, before/after formatting demo, and honest caveats on the unstable LSP preview, analyzer false positives, and the lack of a PHP extension ecosystem.
carthage-software/mago, v1.29.0) ships all three as a single Rust binary with no PHP runtime dependency at all. On the same WordPress corpus, it formats in 0.43 seconds and analyzes in 1.46 seconds. 1 The VS Code extension (Clearlyip.mago-vscode-extension v0.9.5) connects via Language Server Protocol — a persistent server process rather than spawning the binary on every keystroke — giving you real-time diagnostics, format-on-save, hover, completions, and inlay hints. 2Why the LSP approach matters
Clearlyip extension instead keeps one persistent language server running and communicates over LSP. 3mago.toml and auto-restarts the server when you modify config, so changes take effect without touching VS Code.If another Mago extension is already installed (e.g.Michael4d45.mago-vscodeorkgz.mago-unofficial), the Clearlyip extension detects it and warns you about duplicate diagnostics. Disable the others before enabling this one.
Five-minute setup
1. Install the LSP-enabled binary
composer require --dev clearlyip/mago-lspvendor/bin/mago-lsp. The VS Code extension checks that path first, then falls back to mago on PATH. 42. Scaffold your config
vendor/bin/mago-lsp initmago.toml to your project root. 53. Install the VS Code extension
code --install-extension Clearlyip.mago-vscode-extension4. Enable format-on-save
.vscode/settings.json:{
"[php]": {
"editor.defaultFormatter": "Clearlyip.mago-vscode-extension",
"editor.formatOnSave": true
}
}The .mago.toml config
#:schema https://mago.carthage.software/1.29.0/schema.json
version = "1"
php-version = "8.3"
[source]
paths = ["src", "tests"]
includes = ["vendor"]
excludes = ["vendor/bin"]
[formatter]
print-width = 120
single-quote = true
trailing-comma = true#:schema comment gives you autocomplete in Taplo (the TOML LSP). 6[formatter] preset = "...": default (PER-CS — PHP Evolving Recommendation Coding Standard), psr-12, laravel (mirrors Laravel Pint), and drupal. You can combine a preset with individual overrides — Mago applies the preset first, then the explicit options on top. 7<?php
use App\Models\{ User, Post };
use App\Services\AuthService;
class UserController {
function __construct(private readonly AuthService $auth) {}
function index(): array {
return [
"users" => User::all(),
"posts" => Post::all()
];
}
}
?><?php
use App\Models\Post;
use App\Models\User;
use App\Services\AuthService;
class UserController
{
public function __construct(private readonly AuthService $auth) {}
public function index(): array
{
return [
'users' => User::all(),
'posts' => Post::all(),
];
}
}use statements into individual imports, alphabetizes them, converts double-quoted strings to single quotes, adds trailing commas to multi-line arrays, removes the closing ?> tag, and puts <?php on its own line with a blank line after — all without touching the AST. 7
What to know before switching
"mago.noAnalyzer": true and use only the formatter and linter.Install
Clearlyip.mago-vscode-extension · Version: v0.9.5 (extension), v1.29.0 (Mago binary, released 2026-05-23) · IDE: VS Code ≥ 1.95.0 · Language: PHP (≥ 8.1) · Use case: Linting, formatting, static analysis (LSP) · Publisher: Clearlyip · GitHub stars: 3.2k (Mago core), JetBrains is a financial sponsor 12 · Packagist installs: 965k 13References
- 1Benchmarks · Mago
mago.carthage.software
- 2Mago LSP — Visual Studio Marketplace
marketplace.visualstudio.com
- 3clearlyip/mago-vscode-extension
github.com
- 4Installation · Mago
mago.carthage.software
- 5Initialization · Mago
mago.carthage.software
- 6Configuration · Mago
mago.carthage.software
- 7Formatter configuration reference · Mago
mago.carthage.software
- 8
- 9
- 10FAQ · Mago
mago.carthage.software
- 11Formatter · Mago
mago.carthage.software
- 12carthage-software/mago
github.com
- 13carthage-software/mago — Packagist
packagist.org
This story was produced automatically by a channel. One sentence is all it takes for Neodrop to keep producing for you.
