ssch/typo3-rector
Automated upgrades and refactoring for TYPO3 sites and extensions using Rector. Apply version migrations, remove deprecations, and modernize code safely in development with configurable rule sets for TYPO3 7–12+.
Installation:
composer require --dev ssch/typo3-rector
vendor/bin/typo3-init
This generates a basic rector.php config file in your project root.
First Dry Run:
vendor/bin/rector process --dry-run
Review the output to understand what changes will be applied without modifying your code.
Apply Changes:
vendor/bin/rector process
Run this only after verifying the dry run output.
rector.php to customize rulesets and paths. Example:
return RectorConfig::configure()
->withSets([
Typo3SetList::TYPO3_120,
Typo3SetList::TCA_120,
])
->withPaths([__DIR__ . '/Classes']);
ClassAliasMap entries to composer.json under extra:
"extra": {
"typo3/class-alias-loader": {
"class-alias-maps": [
"vendor/ssch/typo3-rector/Migrations/TYPO3/10.4/typo3/sysext/core/Migrations/Code/ClassAliasMap.php"
]
}
}
composer require --dev ssch/typo3-rector
vendor/bin/typo3-init
return RectorConfig::configure()
->withSets([
Typo3SetList::TYPO3_104, // Start with current version
Typo3SetList::TYPO3_115, // Then intermediate versions
Typo3SetList::TYPO3_120, // Finally target version
])
->withPaths([__DIR__ . '/Classes']);
vendor/bin/rector process --dry-run
Test thoroughly before committing changes.Version-Specific Upgrades:
Typo3SetList::TYPO3_XY for core changes (e.g., TYPO3_120 for TYPO3 v12).Typo3SetList::TCA_XY for TCA-specific changes (e.g., TCA_120 for TCA in v12).->withSets([
Typo3SetList::TYPO3_104,
Typo3SetList::TYPO3_115,
Typo3SetList::TYPO3_120,
])
Targeted Path Processing:
->withPaths([
__DIR__ . '/Classes/Controller',
__DIR__ . '/Configuration/TCA/Overrides',
])
Combining Rulesets:
->withSets([
Typo3SetList::TCA_120, // TCA-specific rules
Typo3SetList::TYPO3_120, // Core rules
])
ClassAliasMap for Multi-Version Jumps:
ClassAliasMap for all intermediate versions in composer.json.Pre-Commit Hooks: Add a Git hook to run Rector in dry mode before commits:
# .git/hooks/pre-commit
#!/bin/bash
vendor/bin/rector process --dry-run || exit 1
CI/CD Pipeline: Use Rector in CI to enforce upgrades:
# .github/workflows/rector.yml
jobs:
rector:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: composer require --dev ssch/typo3-rector
- run: vendor/bin/rector process --dry-run
Symfony Container Integration:
For rules like AddAutoconfigureAttributeToClassRector, ensure the Symfony container XML is generated:
->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml')
Clear TYPO3 cache first:
vendor/bin/typo3 cache:flush
Parallel Processing:
Use --parallel for large codebases:
vendor/bin/rector process --parallel
Production Safety:
--dry-run to preview changes:
vendor/bin/rector process --dry-run
Invalid TCA Structures:
ctrl and columns keys). Example:
return [
'ctrl' => [], // Required
'columns' => [], // Required
];
'type' => 'select' for doktype items).ClassAliasMap Misconfiguration:
ClassAliasMap entries will cause Rector to fail silently or apply incorrect migrations."extra": {
"typo3/class-alias-loader": {
"class-alias-maps": [
"vendor/ssch/typo3-rector/Migrations/TYPO3/8.7/typo3/sysext/core/Migrations/Code/ClassAliasMap.php",
"vendor/ssch/typo3-rector/Migrations/TYPO3/10.4/typo3/sysext/core/Migrations/Code/ClassAliasMap.php"
]
}
}
Coding Standards:
composer require --dev symplify/easy-coding-standard
vendor/bin/ecs check src
Symfony Container Dependencies:
AddAutoconfigureAttributeToClassRector require:
ssch/typo3-debug-dump-pass installed.vendor/bin/typo3 cache:flush).rector.php:
->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml')
Partial Rule Application:
ExtEmConfRector) require explicit configuration. Example:
->withRule(ExtEmConfRector::class)
Verbose Output:
Use --verbose to debug rule application:
vendor/bin/rector process --verbose
Rule-Specific Debugging:
vendor/bin/rector process --rules=Ssch\TYPO3Rector\TYPO312\RenameClassConstantRector
Git Diff Analysis: After a dry run, compare changes with Git:
git diff --name-only | xargs vendor/bin/rector process --dry-run
ClassAliasMap Validation:
ClassAliasMap entries by running Rector on a single file:
vendor/bin/rector process Classes/Controller/SomeController.php --dry-run
// CustomRector.php
namespace App\Rector;
use PhpParser\Node;
use Rector\Core\Rector\AbstractRector;
class CustomR
How can I help you explore Laravel packages today?