Rector migration

Automatic migration of Neos 8.3 packages

To ensure the smoothest possible upgrade path, we offer a migration for Rector

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

Manual action required

As not all places can get migrated automatically, the migration will also add "todos" for you, where a manual change is required.

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

#How to use Rector

#Installation

As Rector has strict dependency requirements, which might not match your own project, we strongly recommend to install neos/rector in a dedicated directory and not to add it to your project.

You can install the neos/rector package with composer as dedicated package within your distribution.

bash
# within the root of your distribution
composer create-project neos/rector:dev-main --stability=dev rector
cp 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 the following sets of Rector rules:

  • \Neos\Rector\NeosRectorSets::CONTENTREPOSITORY_9_0: all rules needed to migrate to the Event-Sourced Content Repository (currently still in progress)
  • \Neos\Rector\NeosRectorSets::NEOS_8_4: all rules needed to migrate to the Event-Sourced Content Repository (currently still in progress)
php
return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        NeosRectorSets::CONTENTREPOSITORY_9_0,
        //NeosRectorSets::NEOS_8_4
    ]);

    $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
# for trying out what would be done
./rector/vendor/bin/rector --dry-run

# for running the migrations
./rector/vendor/bin/rector