MCPcopy Index your code
hub / github.com/carthage-software/mago

github.com/carthage-software/mago @1.43.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.43.0 ↗ · + Follow
33,473 symbols 86,460 edges 4,935 files 8,841 documented · 26%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Mago Banner

An extremely fast PHP linter, formatter, and static analyzer, written in Rust.

CI Status CD Status CodeQL CodSpeed Crates.io Latest Stable Version for PHP Total Composer Downloads License

Mago is a comprehensive toolchain for PHP that helps developers write better code. Inspired by the Rust ecosystem, Mago brings speed, reliability, and an exceptional developer experience to PHP projects of all sizes.

Table of Contents

Installation

The most common way to install Mago on macOS and Linux is by using our shell script:

curl --proto '=https' --tlsv1.2 -sSf https://carthage.software/mago.sh | bash

To install a specific version:

curl --proto '=https' --tlsv1.2 -sSf https://carthage.software/mago.sh | bash -s -- --version=1.43.0

For all other installation methods, including Homebrew, Composer, and Cargo, please refer to our official Installation Guide.

Getting Started

To get started with Mago and learn how to configure your project, please visit our Getting Started Guide in the official documentation.

Features

  • ⚡️ Extremely Fast: Built in Rust for maximum performance.
  • 🔍 Lint: Identify issues in your codebase with customizable rules.
  • 🔬 Static Analysis: Perform deep analysis of your codebase to catch potential type errors and bugs.
  • 🛠️ Automated Fixes: Apply fixes for many lint issues automatically.
  • 📜 Formatting: Automatically format your code to adhere to best practices and style guides.
  • 🧠 Semantic Checks: Ensure code correctness with robust semantic analysis.
  • 🌳 AST Visualization: Explore your code’s structure with Abstract Syntax Tree (AST) parsing.

Our Sponsors

JetBrains

Jason R. McNeilVincent Berset

TicketSwapBohuslav ŠimekHeySora

See all sponsors

Contributing

Mago is a community-driven project, and we welcome contributions! Whether you're reporting bugs, suggesting features, writing documentation, or submitting code, your help is valued.

Inspiration & Acknowledgements

Mago stands on the shoulders of giants. Our design and functionality are heavily inspired by pioneering tools in both the Rust and PHP ecosystems.

Inspirations:

  • Clippy: For its comprehensive linting approach.
  • OXC: A major inspiration for building a high-performance toolchain in Rust.
  • Hakana: For its deep static analysis capabilities.

Acknowledgements:

We deeply respect the foundational work of tools like PHP-CS-Fixer, Psalm, PHPStan, and PHP_CodeSniffer. While Mago aims to offer a unified and faster alternative, these tools paved the way for modern PHP development.

License

Mago is dual-licensed under your choice of the following:

Extension points exported contracts — how you extend this code

CopyInto (Interface)
A deep copy of a value into an arena, rebinding every internal reference. Implementors copy all of their arena-resident [190 …
crates/allocator/src/copy.rs
HasPosition (Interface)
A trait for types that have a single, defined source position. [6 implementers]
crates/span/src/lib.rs
Formatter (Interface)
Trait for formatting issues to a writer. [12 implementers]
crates/reporting/src/formatter/mod.rs
TType (Interface)
A trait to be implemented by all types in the type system. [35 implementers]
crates/codex/src/ttype/mod.rs
Config (Interface)
(no doc) [187 implementers]
crates/linter/src/rule/mod.rs
Analyzable (Interface)
(no doc) [94 implementers]
crates/analyzer/src/analyzable.rs
HasFileId (Interface)
(no doc) [13 implementers]
crates/database/src/file.rs
Fingerprintable (Interface)
(no doc) [213 implementers]
crates/fingerprint/src/lib.rs

Core symbols most depended-on inside this repo

with_message
called by 1646
crates/reporting/src/lib.rs
with_annotation
called by 1617
crates/reporting/src/lib.rs
push
called by 1384
crates/linter/src/scope.rs
iter
called by 1289
crates/names/src/lib.rs
as_ref
called by 1084
crates/word/src/word.rs
with_help
called by 948
crates/reporting/src/lib.rs
span
called by 943
crates/syntax-core/src/cst/mod.rs
with_note
called by 870
crates/reporting/src/lib.rs

Shape

Method 14,807
Function 12,406
Class 5,120
Interface 575
Enum 565

Languages

PHP59%
Rust41%
TypeScript1%

Modules by API surface

crates/prelude/assets/extensions/standard.php577 symbols
crates/prelude/assets/extensions/imagick.php553 symbols
crates/prelude/assets/extensions/intl.php531 symbols
crates/prelude/assets/extensions/spl.php443 symbols
crates/prelude/assets/extensions/mongodb.php407 symbols
crates/syntax/benches/fixtures/large.php393 symbols
crates/prelude/assets/extensions/dom.php364 symbols
crates/prelude/assets/extensions/reflection.php308 symbols
crates/analyzer/tests/cases/unused_edge_cases.php279 symbols
crates/prelude/assets/extensions/redis.php269 symbols
crates/prelude/assets/extensions/core.php206 symbols
crates/prelude/assets/extensions/mysqli.php196 symbols

For agents

$ claude mcp add mago \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact