rector
10,506
Stars
0
Forks
0
Watchers
0
Open Issues
未知
许可证
PHP
语言
创建时间
最近更新
项目能做什么
支持 PHP 5.3+ 代码即时版本升级与自动化重构的工具。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Rector - Instant Upgrades and Automated Refactoring
[](https://packagist.org/packages/rector/rector)
<br>
Rector instantly upgrades and refactors the PHP code of your application. It can help you in 2 major areas:
### 1. Instant Upgrades
Rector now supports upgrades from PHP 5.3 to 8.5 and major open-source projects like [Symfony](https://github.com/rectorphp/rector-symfony), [PHPUnit](https://github.com/rectorphp/rector-phpunit), and [Doctrine](https://github.com/rectorphp/rector-doctrine). Do you want to **be constantly on the latest PHP and Framework without effort**?
Use Rector to handle **instant upgrades** for you.
### 2. Automated Refactoring
Do you have code quality you need, but struggle to keep it with new developers in your team? Do you want to see smart code-reviews even when every senior developers sleeps?
Add Rector to your CI and let it **continuously refactor your code** and keep the code quality high.
Read our [blogpost](https://getrector.com/blog/new-setup-ci-command-to-let-rector-work-for-you) to see how to set up automated refactoring.
## Install
```bash
composer require rector/rector --dev
```
## Running Rector
There are 2 main ways to use Rector:
- a *single rule*, to have the change under control
- or group of rules called *sets*
To use them, create a `rector.php` in your root directory:
```bash
vendor/bin/rector
```
And modify it:
```php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
return RectorConfig::configure()
// register single rule
->withRules([
TypedPropertyFromStrictConstructorRector::class
])
// here we can define, what prepared sets of rules will be applied
->withPreparedSets(
deadCode: true,
codeQuality: true
);
```
Then dry run Rector:
```bash
vendor/bin/rector src --dry-run
```
Rector will show you diff of files that it *would* change. To *make* the changes, drop `--dry-run`:
```bash
vendor/bin/rector src
```
## Documentation
* Find [full documentation here](https://getrector.com/documentation/).
* [Explore Rector Rules](https://getrector.com/find-rule)
<br>
## Learn Faster with a Book
Are you curious, how Rector works internally, how to create your own rules and test them and why Rector was born?
Read [Rector - The Power of Automated Refactoring](https://leanpub.com/rector-the-power-of-automated-refactoring) that will take you step by step through the Rector setup and how to create your own rules.
<br>
## Empowered by Community :heart:
The Rector community is powerful thanks to active maintainers who take care of Rector sets for particular projects.
Among there projects belong:
* [palantirnet/drupal-rector](https://github.com/palantirnet/drupal-rector)
* [craftcms/rector](https://github.com/craftcms/rector)
* [FriendsOfShopware/shopware-rector](https://github.com/FriendsO
阅读完整原文
商业机会分析 AI 生成
遗留PHP系统现代化升级与定制规则技术咨询
| 产品构想 | 依托Rector的AST语法转换能力,面向拥有庞大历史PHP代码(如PHP 5/7升级8+、自研框架转主流框架)的企业,提供工程化迁移与私有规则定制服务。 |
| 核心功能 | 代码库迁移风险评估、针对内部私有库的定制Rector规则编写、CI自动化升级流水线配置、单元测试覆盖与变更验证支持。 |
| 目标用户 | 拥有长期技术债务的中大型PHP企业、金融/电商类自研系统维护团队。 |
| 难度/周期 | 中等 · 1 - 3 个月(按项目计) · 成本:极低(主要为人力与时间成本) |
| 收费模式 | 项目制咨询费、阶段性交付费用、企业培训/私有规则买断。 |
| 竞争风险 | 老旧系统缺少测试导致自动化改写出现隐蔽运行时Bug;单人交付规模有限,获客周期较长。 |
| 依据 | 已验证事实 |
商业垂直生态专用规则订阅包(如Magento/Shopware等电商与ERP)
| 产品构想 | 针对生态复杂且客单价高的特定PHP商业CMS/电商系统,开发高覆盖度、深度处理破损变更(Breaking Changes)的高级升级规则包,采用订阅制售卖。 |
| 核心功能 | 深度AST模式匹配(含模板/配置关联)、复杂废弃API兼容映射、跨大版本无损自动化重构脚本、月度规则维护与工单支持。 |
| 目标用户 | Magento/Shopware/Typo3服务商、独立软件开发商(ISV)、电商自建站技术团队。 |
| 难度/周期 | 高 · 2 - 4 个月 · 成本:低(需对特定商业框架生态有深度理解) |
| 收费模式 | 开发者授权许可年费、企业级规则订阅制(SaaS/私有Composer源)。 |
| 竞争风险 | 小众生态市场空间有限,维护成本随上游框架频繁迭代而递增。 |
| 依据 | 数据支持的判断 |
Rector-as-a-Service:云端自动重构与代码现代化PR机器人
| 产品构想 | 封装Rector为GitHub/GitLab App,免去本地复杂配置,提供代码库一键升级检测、定时自动化提交重构PR及风险解释报告。 |
| 核心功能 | GitHub/GitLab免配置集成、增量代码AST分析、自动创建重构Pull Request、变更风险评级与可视化Diff展示。 |
| 目标用户 | 缺乏专职架构师的中小型开发团队、开源项目维护者、希望降低CI维护门槛的技术主管。 |
| 难度/周期 | 中等 · 2 - 3 个月 · 成本:低(基础云服务器及计算容器) |
| 收费模式 | 免费版(针对开源/个人)+ 团队按仓库数/按席位月费订阅(Freemium)。 |
| 竞争风险 | 企业对源代码外发到第三方SaaS的安全性顾虑(需推测是否需纯私有化部署支持)。 |
| 依据 | AI推测 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
| 项目 | 中文简介 | Stars | 语言 |
|---|---|---|---|
| Graphify-Labs/graphify | 中文介绍暂未生成 Turn any codebase, with its docs, SQL schemas, configs, and |
146,070 | Python |
| withastro/astro | 中文介绍暂未生成 The web framework for content-driven websites. |
63,898 | TypeScript |
| prettier/prettier | 中文介绍暂未生成 Prettier is an opinionated code formatter. |
52,406 | JavaScript |
| DeusData/codebase-memory-mcp | 中文介绍暂未生成 Local code intelligence for developers and AI agents. Connec |
48,504 | C |
| AstrBotDevs/AstrBot | 中文介绍暂未生成 AI Agent Assistant & development framework that integrates l |
46,703 | Python |
| babel/babel | 中文介绍暂未生成 🐠 Babel is a compiler for writing next generation JavaScript |
44,057 | TypeScript |
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。
项目优势与风险
| 技术成熟度 | 创建于 ,最近推送 ,发布过 100 个 Release |
| 社区活跃 | Star 10,506 / Fork 0 / Issue 0(数据支持,可自行核实) |
| 许可证 | 未检测到(需人工确认) |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
快速开始(以仓库 README 为准)
git clone https://github.com/rectorphp/rector.git cd rector # 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。