MMago for VS Code

Getting Started

For mago CLI documentation — formatting rules, linter configuration, and analysis options — see mago on GitHub.

Requirements

  • VS Code 1.75 or later
  • mago CLI installed and accessible

Installation

From the VS Code Marketplace (recommended)

  1. Open VS Code
  2. Press ⌃⇧X (⌘⇧X on MacOS) to open the Extensions panel
  3. Search for "Mago PHP Toolchain"
  4. Click Install

Or install from the command line:

code --install-extension kellymears.vscode-mago

View on Marketplace →

Build from source

git clone https://github.com/kellymears/vscode-mago
cd vscode-mago
npm install && npm run build
npx vsce package
 
# Install the .vsix
code --install-extension vscode-mago-*.vsix

Quick Setup

  1. Install the mago binary in your project or globally:
# Via Composer (project-local)
composer require carthage-software/mago
 
# Or download the binary directly
# See https://github.com/carthage-software/mago
  1. Open a PHP project in VS Code.
  2. The extension activates automatically when a PHP file is opened.
  3. Set Mago as your default PHP formatter:
{
"editor.defaultFormatter": "kellymears.vscode-mago",
"editor.formatOnSave": true,
"[php]": {
"editor.defaultFormatter": "kellymears.vscode-mago"
}
}
{
"editor.defaultFormatter": "kellymears.vscode-mago",
"editor.formatOnSave": true,
"[php]": {
"editor.defaultFormatter": "kellymears.vscode-mago"
}
}

Binary Resolution

The extension searches for the mago binary in the following order, using the first executable it finds:

  1. mago.bin setting — explicit path in VS Code settings
  2. ./vendor/bin/mago — Composer local install
  3. ./mago — binary in workspace root
  4. System $PATH — global install

If none are found, the extension shows an error notification. Set mago.bin in your configuration to use a specific path.

Verify

Open a PHP file and check the status bar — you should see mago with the CLI version in the bottom-right. If you see an error icon, check that the binary is installed and accessible.

Open the command palette (⌃⇧P / ⌘⇧P) and type "Mago" to see all available commands.