Best way to bootstrap + configure Rector programatically? #7026
-
I would like to include a binary in a Rector rule set package, which provides a no-config way of bootstrapping rector with a given ruleset, without needing to provide their own So for example, someone could run the following: composer require craftcms/rector --dev
vendor/bin/upgrade-craftcms-v4 src And that would be equivalent to running So: what’s the best way to bootstrap and configure Rector programmatically from the binary? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, thanks for question. I There are basically 2 ways.
vendor/bin/rector process src --config vendor/craftcms-rector/config/craftcms-40.php There will be more versions to upgrade, and people tent to stick with know syntax, so I recommend using the first one and keep the config in CI. |
Beta Was this translation helpful? Give feedback.
Hi, thanks for question. I
There are basically 2 ways.
make use of init command - https://github.com/KnpLabs/DoctrineBehaviors#upgrade-1x-to-2, this is helpful for gradual upgrade and dry run. It's safer to upgrade rule by rule and path by path, so the existing config helps with ignoring files before full upgrade merge
prepare the same config with defined rules, but use
--config
option to link it:There will be more versions to upgrade, and people tent to stick with know syntax, so I recommend using the first one and keep the config in CI.