- Can Mago replace PHPStan and Psalm for Laravel static analysis?
- Mago can replace PHPStan and Psalm for basic static analysis in Laravel, but it lacks native support for Laravel-specific features like route model binding or service container validation. Start with linting/formatting (low risk) before enabling static analysis, and supplement with custom rules for Laravel patterns.
- How does Mago handle Blade templates in Laravel?
- Mago doesn’t natively parse Blade syntax, so it won’t analyze template logic. Exclude Blade files using `--ignore` flags or `.magoignore`, or pair it with a dedicated tool like `blade-analyzer` for template security checks (e.g., XSS/SQLi risks).
- What Laravel versions does Mago support?
- Mago works with any Laravel version (5.8+) since it operates on PHP code, not Laravel-specific APIs. However, static analysis may misinterpret dynamic Laravel features (e.g., `__call()`, magic methods). Use `--level` flags to adjust sensitivity or write custom rules for Laravel patterns.
- How do I integrate Mago into Laravel’s CI/CD pipeline?
- Mago supports GitHub Actions annotations (`--reporting-format=github`) and JUnit XML for CI tools. Benchmark performance on your Laravel repo first—static analysis adds minimal overhead (often <1s for 10K+ lines). Cache Rust binaries in Docker to speed up CI builds.
- Does Mago auto-fix Laravel coding standards (e.g., PSR-12)?
- Yes, Mago auto-fixes formatting issues (e.g., PSR-12) and basic linting errors out of the box. For Laravel-specific standards (e.g., route naming conventions), create custom rules or extend existing ones via Mago’s plugin system.
- Will Mago break existing Laravel projects during static analysis?
- Mago is designed to be non-breaking when used in `--check` mode first. Start with linting/formatting, then gradually enable static analysis. False positives (e.g., from Laravel’s dynamic features) can be tuned with `--level` or custom rules.
- How does Mago’s performance compare to PHPStan/Psalm in Laravel?
- Mago is significantly faster (Rust-based) than PHPStan/Psalm, often completing analysis in milliseconds for large Laravel apps. Benchmark your project: Mago typically processes 10K+ lines of PHP in under 1 second, while PHPStan/Psalm may take 5–10x longer.
- Can I use Mago alongside Laravel Pint or PHP-CS-Fixer?
- Mago replaces Pint and PHP-CS-Fixer for formatting/linting, but you can run them in parallel during migration. Use Mago’s `--check` mode to verify consistency before fully adopting it. For hybrid setups, exclude files processed by other tools via `.magoignore`.
- Are there Laravel-specific rules or plugins for Mago?
- Mago doesn’t include Laravel-specific rules out of the box, but you can create custom rules (e.g., `NoHardcodedRoutes`, `ValidateServiceBindings`) using its plugin system. Check the [community rules repository](https://github.com/carthage-software/mago-rules) for examples.
- What’s the best way to handle false positives in Mago’s static analysis for Laravel?
- Start by adjusting the analysis level (`--level=1` for basic checks). For Laravel-specific false positives (e.g., dynamic properties), write custom rules or suppress issues with `// @mago-ignore`. Document your triage process for the team to ensure consistent handling.