Replies: 1 comment 5 replies
-
|
Thanks for proposal. How is it superior to SetProviders? They handle config autoloading. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be useful if Rector could automatically load configuration files provided by third-party packages (e.g. framework-specific rule sets such as Laravel Rector).
This avoids each user needing to manually import configs in their own rector.php, and allows packages to self-register additional rules or settings in a clean, Composer-native way.
Motivation
Many ecosystem packages ship additional Rector rules, sets, or configuration. Right now each user must manually add:
This is an extra step for things like rules that rely on NodeVisitors that silently fail when a set of NodeVisitors haven't been used.
Composer already supports the extra section for package-specific metadata.
Proposed solution
Example for a package providing Rector rules:
{ "extra": { "rector": { "config": "rector.php" } } }This path would be relative to the package root, e.g.:
vendor/vendor-name/package/rector.php
The package can expose any number of rules or configuration inside that file.
During config loading, Rector would:
1. Read vendor/composer/installed.json
2. Look for packages containing "extra.rector.config"
3. Import the referenced file before applying the user’s own rector.php
Pseudo-implementation:
This provides a deterministic, explicit discovery mechanism without the downsides of Composer plugins or runtime directory scanning.
Benefits
• Zero-setup for end users installing rule-set packages
• Explicit and stable — discovery controlled entirely via composer.json
• Plays well with existing Rector config structure
Backwards compatibility
• No breaking changes
• Auto-discovery can be enabled by default or behind a small toggle
• Users can still manually import files as usual
Example use case
Laravel Rector could ship:
composer.json
rector-laravel.php
{ "extra": { "rector": { "config": "rector-laravel.php" } } }On install, Rector would automatically load the Laravel-specific rules with no extra work required by the user.
Beta Was this translation helpful? Give feedback.
All reactions