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).
mago guard is a powerful architectural validation utility for enforcing boundaries and coding standards within a PHP project. It acts as a high-performance, single-binary replacement for tools like deptrac (for dependency validation) and arkitect (for structural rule enforcement).
Think of it as a two-part fortress for your codebase: the Perimeter Guard and the Structural Guard.
The Perimeter Guard is responsible for dependency validation. It ensures that different parts of your application only communicate in ways you've explicitly allowed. Its primary goal is to protect your architectural layers and prevent invalid dependencies from crossing into your core domain logic.
For example, you can enforce rules like:
Domain layer must not depend on any other layer.UI layer can depend on the Application layer, but not the other way around.This is crucial for maintaining a clean, decoupled architecture that is easy to maintain and scale.
The Structural Guard is responsible for enforcing coding conventions on the symbols themselves. It inspects the internal structure of your code to ensure it follows a consistent and predictable pattern.
For example, you can enforce rules like:
App\Http\Controllers namespace must be final and have names ending in Controller.Domain must be named with an Interface suffix.enum definitions.This helps maintain a high level of code quality and consistency across the entire project.
guard settings in mago.toml.How can I help you explore Laravel packages today?