Rector migration

Automatic migration of Neos 8.3 packages

To ensure the smoothest possible upgrade path, we offer a migration to be run using Rector

The Rector migration is applied to your custom packages and rewrites the PHP source code to Neos 9 accordingly.

Manual action required

As not all places can be migrated automatically, the migration will also add TODO comments where a manual change is required.

php
// TODO 9.0 migration: Line 26: You very likely need to rewrite ...

#How to use Rector

#Installation

Please install the neos/rector package in your Distribution as a dev dependency with composer.

Note: This has changed from previous versions of this package.

bash
# inside your Distribution folder
composer require --dev neos/rector:dev-main
cp Packages/Libraries/neos/rector/rector.template.php rector.php

#Configuration

Now, open up the rector.php file copied above, and adjust the Rector Paths (these are the paths which shall be migrated). By default, all of ./DistributionPackages will be migrated.

Right now, we ship a single set of Rector rules:

  • \Neos\Rector\NeosRectorSets::CONTENTREPOSITORY_9_0: all rules needed to migrate to the Event-Sourced Content Repository (Neos 9.x)
rector.php
return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        NeosRectorSets::CONTENTREPOSITORY_9_0,
    ]);

    $rectorConfig->paths([
        // TODO: Start adding your paths here, like so:
        __DIR__ . '/DistributionPackages/'
    ]);
};

#Running

Run the following command at the root of your distribution (i.e. where rector.php is located).

bash
# to preview what would change
./bin/rector --dry-run

# to run the migrations
./bin/rector

Check the migrated code thoroughly and try to solve all open TODOs, which are generated by the rector migration.