contao/contao-rector
Automate Contao upgrades with Rector. This package provides ready-made Rector rules and configuration to refactor Contao projects for newer versions, helping you modernize code, remove deprecations, and apply consistent changes safely across your codebase.
contao/contao-rector package provides Rector rules tailored for Contao CMS, a PHP-based content management system. It enables automated refactoring of legacy Contao codebases (e.g., PHP 7.4 → PHP 8.1+) while preserving Contao-specific patterns (e.g., tl_* database tables, DCA structures, hooks, and legacy syntax).rector/rector) as a base tool (PHP 8.0+).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Rule Overlap | Contao rules may conflict with generic Rector rules (e.g., tl_* vs. custom table names). |
Test on a staging clone of the codebase; use --dry-run first. |
| False Positives | Legacy Contao patterns (e.g., {$var} syntax in templates) may break. |
Exclude template files (*.tpl, *.html5) from Rector’s scope; validate manually. |
| Performance Impact | Large codebases may slow down CI pipelines. | Run in parallel (Rector supports --parallel) or incremental mode. |
| Backward Compatibility | Refactored code may break custom Contao hooks or third-party extensions. | Test with all active extensions; use contao/behat for integration testing. |
tl_content elements) that need preservation?tl_* tables, {$var} syntax, \Contao\* classes).--dry-run) to preview changes.tl_content refactoring).| Component | Compatibility Notes |
|---|---|
| Contao Version | Tested with Contao 4.x (PHP 7.4+) and Contao 5.x (PHP 8.1+). |
| PHP Version | Requires Rector 0.15+ (PHP 8.0+). Target PHP version must be ≥7.4. |
| Custom Extensions | May need rule exclusions if extensions use non-standard Contao patterns. |
| Database Schema | No direct impact, but legacy SQL queries (e.g., mysql_* functions) may need refactoring. |
| Frontend Templates | Exclude .tpl/.html5 files unless using Contao’s new template engine. |
vendor/bin/rector process src --dry-run --rules="[Contao\Rector\Set\Contao74Set]"
contao/core-bundle to PHP 8.1+ compatible version).assets system).contao/contao-rector for new Contao versions (e.g., Contao 5.x rules).composer.json to avoid breaking changes."require-dev": {
"rector/rector": "^0.15",
"contao/contao-rector": "^1.0"
}
tl_content refactoring).vendor/, templates/).onLoadTemplate → onLoad).--show-skipped to identify unprocessed files.rector.log for errors.--parallel=4 to speed up execution.models/ → PHP 8.1 rules, dca/ → Contao-specific rules).| Failure Scenario | Detection Method | Recovery Plan |
|---|---|---|
| Broken Backend Modules | Manual QA + Contao’s behat tests |
Roll back to pre |
How can I help you explore Laravel packages today?