ibexa/rector
Rector rule sets for upgrading Ibexa DXP projects between versions. Install as a dev dependency, add an ibexa set (e.g., IBEXA_50) to rector.php, and run Rector to automatically refactor code for the target Ibexa release.
Install the Package
Add to your composer.json under require-dev:
composer require --dev ibexa/rector:^5.0
Create Rector Config
Generate a minimal rector.php in your project root:
declare(strict_types=1);
use Ibexa\Contracts\Rector\Sets\IbexaSetList;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
->withSets([IbexaSetList::IBEXA_50]);
Run a Dry Test Validate changes before applying:
php vendor/bin/rector process src --dry-run
Apply Changes Once confirmed, run:
php vendor/bin/rector process src
ezpublish namespace → ibexa).IBEXA_50 set in rector.php.src/ and tests/ directories.IbexaSetList::IBEXA_XY constants to target specific Ibexa versions.
// For Ibexa 4.6 → 5.0
->withSets([IbexaSetList::IBEXA_50])
->withSets([
IbexaSetList::IBEXA_46_TO_50, // Custom intermediate set
IbexaSetList::IBEXA_50
])
src/Controller/):
->withPaths([__DIR__ . '/src/Controller'])
ezplatform bundles).phpunit.xml or Git hooks:
<!-- phpunit.xml -->
<php>
<env name="RECTOR_PROCESS" value="1"/>
</php>
if [ "$RECTOR_PROCESS" = "1" ]; then
php vendor/bin/rector process src --dry-run
fi
use Ibexa\Rector\Set\IbexaSetList;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withSets([IbexaSetList::IBEXA_50])
->withCustomRuleSets([new CustomIbexaRuleSet()]);
ezplatform services:
class RenameEzplatformServices extends AbstractRector {
public function refactor(PhpNode $node): ?PhpNode {
// Logic to rename services
}
}
rector/rector’s Laravel rules alongside Ibexa sets:
->withSets([
IbexaSetList::IBEXA_50,
Rector\Set\LaravelSetList::LARAVEL_90
])
ibexa/migrations for schema updates:
php vendor/bin/rector process src
php vendor/bin/ibexa migrations:migrate
php vendor/bin/rector process src --parallel
php artisan test
False Positives in Dry Runs
--skip-errors-on-warnings or manually review diffs:
php vendor/bin/rector process src --dry-run --skip-errors-on-warnings
Namespace Collisions
ezpublish → ibexa rename may conflict with custom namespaces.->withExcludedPaths([__DIR__ . '/vendor', __DIR__ . '/custom-ez'])
PHP Version Mismatches
FROM php:8.1-cli
RUN composer require ibexa/rector:^5.0
Stateful Refactors
RemoveLegacyClassAliasRector) may break builds if not applied fully.--parallel for large codebases.php vendor/bin/rector process src --verbose
Rector\Logging\LoggerInterface to custom rules for debugging:
public function __construct(private LoggerInterface $logger) {}
$this->logger->info('Processing node: ' . $node->getType());
->withCache(false)
--parallel for multi-core speedups (but test thoroughly):
php vendor/bin/rector process src --parallel
php bin/console debug:container to validate services.Custom Rule Sets
CustomIbexaRuleSet class extending AbstractRuleSet:
class CustomIbexaRuleSet extends AbstractRuleSet {
public function getRules(): array {
return [
new RenameEzplatformServices(),
];
}
}
->withCustomRuleSets([new CustomIbexaRuleSet()])
Pre/Post-Refactor Hooks
Rector\Contract\Rector\RectorInterface to add logic:
class PreRefactorValidator extends AbstractRector {
public function refactor(PhpNode $node): ?PhpNode {
if ($node instanceof ClassMethod && $node->name->toString() === 'legacyMethod') {
throw new \RuntimeException('Skip refactor: method is legacy.');
}
return null;
}
}
Integration with Ibexa CLI
composer.json:
"scripts": {
"rector": "vendor/bin/rector process src",
"rector:dry": "vendor/bin/rector process src --dry-run"
}
composer rector
How can I help you explore Laravel packages today?