carthage-software/mago
Mago is an extremely fast PHP linter, formatter, and static analyzer written in Rust. It brings Rust-inspired speed and reliability to PHP projects with a modern toolchain and great developer experience, plus multiple install options (script, Homebrew, Composer).
The mago guard command is the entry point for running Mago's architectural guard.
:::tip
For global options that can be used with any command, see the Command-Line Interface overview. Remember to specify global options before the guard command.
:::
Usage: mago guard [OPTIONS] [PATHS]...
[PATHS]...Optional. A list of specific files or directories to analyze. If you provide paths here, they will be used instead of the paths defined in your mago.toml configuration.
These flags control which guard checks are executed. They are mutually exclusive.
| Flag | Description |
|---|---|
--structural |
Run only structural guard checks (naming conventions, modifiers, inheritance constraints). |
--perimeter |
Run only perimeter guard checks (dependency boundaries, layer restrictions). |
If neither flag is specified, both structural and perimeter guards will run (equivalent to mode = "default" in configuration).
:::tip
These flags override the mode setting in your mago.toml configuration. If you specify a flag that matches the configured mode, a warning will be shown indicating the flag is redundant.
:::
| Flag | Description |
|---|---|
--no-stubs |
Disable built-in PHP and library stubs. May result in more warnings when external symbols can't be resolved. |
--stdin-input |
Read file content from stdin and use the single path argument for baseline and reporting. Intended for editor integrations (e.g. unsaved buffers). Requires exactly one path. |
When using an editor or IDE that can pipe unsaved buffer content, you can run the guard on that content while still using the real file path for baseline lookup and issue locations:
cat src/Example.php | mago guard --stdin-input src/Example.php
You must pass exactly one path; it is used as the logical file name (workspace-relative) for baseline matching and diagnostics. The path is normalized (e.g. ./src/Example.php is treated like src/Example.php).
The guard command uses a shared set of options for reporting the issues it finds.
See the Shared Reporting and Fixing Options documentation.
:::info
Auto-fixing and baseline features are not applicable to the guard command.
:::
| Flag, Alias(es) | Description |
|---|---|
--help, -h |
Print the help summary for the command. |
How can I help you explore Laravel packages today?