Mago:用Rust编写的快速PHP工具链
Mago: A fast PHP toolchain written in Rust

原始链接: https://github.com/carthage-software/mago

## Mago:现代PHP工具链 Mago是一个用Rust构建的极速PHP代码检查器、格式化工具和静态分析器,旨在通过速度和可靠性提升PHP开发体验。它借鉴了Rust生态系统的工具设计,提供全面的代码分析,通过可定制的linting规则识别问题,并执行深入的语义检查以捕获错误。 主要特性包括自动化代码修复、自动格式化以符合编码规范,以及AST可视化以理解代码结构。安装方式简单,可以通过shell脚本(macOS/Linux)或Homebrew、Composer、Cargo进行安装。 Mago的灵感来源于Clippy、OXC和Hakana等工具,同时也认可PHP-CS-Fixer、Psalm和PHPStan等现有PHP工具的贡献。它是一个社区驱动、双许可的项目,欢迎所有开发者的贡献。

## Mago:一种用 Rust 构建的新 PHP 工具链 - 摘要 Mago 是一种用 Rust 构建的新的、快速的 PHP 工具链,旨在改进静态分析和代码检查。虽然它有望比 PHPStan 和 Psalm 等成熟工具更快,但早期反馈表明它目前处于 Beta 阶段,功能存在显著差距,特别是缺乏完整的 PHPDoc 解析以及对 PHP 核心功能(如内置异常)的支持。 作者承认这些不足,并强调正在进行的工作以解决这些问题,重点是魔术方法和属性标签的支持。他们的目标不是完全替代现有工具,而是利用 Rust 的性能优势采取不同的方法。 讨论还涉及在 PHP 生态系统中获得关注的挑战、Rust 改进跨语言工具的潜力,以及与类似项目(如 FrankenPHP)的比较。尽管雄心勃勃,Mago 在采用新 PHP 功能方面的灵活性可能是一个关键的差异化因素,可以比当前依赖驱动的方法更快地支持即将到来的语言变化。然而,它的成功取决于实现功能对等,并说服 PHP 开发者采用非 PHP 工具。
相关文章

原文

Mago Banner

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

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.

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

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

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

  • ⚡️ 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.

Jason R. McNeilVincent Berset

TicketSwap

See all sponsors

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.

  • 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.

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.

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

联系我们 contact @ memedata.com