rector/rector-symfony
Rector rules for Symfony that automate framework upgrades and code modernization. Apply automated refactorings across Symfony projects, including deprecation fixes and version migrations, using the Rector tool.
Architecture fit. rector/rector-symfony is not a runtime library — it is a set of Rector rules (declarative AST transformations) packaged as a split from the main Rector distribution. It is a dev-only dependency with zero production footprint, wired in through rector.php via ->withSets([SymfonySetList::...]). Architecturally this is a low-risk, additive tool: it touches nothing at runtime, requires no framework bootstrapping beyond what Rector already does, and is gated by CI.
Critical scope note. Despite being framed as a "Laravel/PHP" package, this is a Symfony-specific ruleset. It has no direct value for pure Laravel application code — Laravel modernization lives in rectorphp/rector (core) and driftingly/rector-laravel. Realistic fit for a Laravel-centric shop is limited to: (a) in-house packages that support Symfony versions, (b) Symfony components inside the dependency graph (HttpFoundation, Console, Finder, Process, VarDumper), and (c) legacy Symfony services/bundles being migrated into or alongside the Laravel stack. Confirm we actually own Symfony-versioned code before sponsoring adoption.
Integration feasibility. High. composer require --dev rector/rector rector/rector-symfony, add a set to rector.php, run vendor/bin/rector process --dry-run to preview, then apply. No schema changes, no service registration, no deployment pipeline changes beyond a CI job. Reversible via git.
Technical risk.
rector/rector-symfony major must track rector/rector major; Symfony set lists are version-gated (5.4 → 6.0 → 6.4 → 7.x). Misaligned pins silently no-op or error.rector/rector rather than installing the split directly. Still, verify via Packagist download stats before treating maturity as proven.Key questions for the team.
Stack fit. Low-friction, dev-toolchain-only. It sits alongside PHPStan, Pint/CS-Fixer, and PHPUnit as a static-analysis-adjacent step. No application code changes, no container/DI impact, no runtime dependency tree pollution.
Migration path.
rector/rector + rector/rector-symfony as require-dev, pinned to exact minors.--dry-run and archive the output as the "before" snapshot.Compatibility. Hard constraints: PHP floor of the target Symfony version, Rector major version, and Symfony major version. Maintain a compatibility matrix in the repo README. If the codebase spans multiple Symfony versions (multi-package monorepo), run the tool per-package with scoped withPaths() rather than repo-wide.
Sequencing recommendation. Do not bundle the Symfony upgrade with an unrelated framework or PHP-version migration. Land the Rector tooling and baseline in sprint N, run the Symfony ladder in sprints N+1 and N+2, and keep a dedicated branch per version hop so any hop can be reverted independently.
Maintenance. Low steady-state: a pinned dev dependency upgraded on the same cadence as Rector itself (~2–4 minor bumps/year). The ruleset must be re-evaluated at each Symfony major release. Budget roughly one engineer-day per Symfony major cycle plus the migration effort itself.
Support. Community-only — GitHub issues, no SLA. Acceptable for a dev tool where failure means "we fix the diff by hand," not "production is down." Escalation option exists via paid Rector consulting if the migration becomes business-critical.
Scaling. Rules execute per-file and scale linearly with codebase size; a mid-size codebase (5k–20k files) will take minutes. Use Rector's parallel mode and CI caching. Memory ceilings are the realistic constraint on very large monorepos — expect to shard by path.
Failure modes and mitigations.
withPaths() to exclude unparseable legacy dirs; document the exclusion list.rector.php and version-pin it; treat it as code, not local config.Ramp-up. Low for engineers already comfortable with static analysis; roughly half a day to configure and validate the first ruleset, one to two days to train the team on diff-review discipline. The real cost is review bandwidth during the migration window, not tooling. Recommend designating a single Rector champion to own config, rule selection, and the upgrade ladder — otherwise the tool stalls after the initial run.
How can I help you explore Laravel packages today?