Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rector Config Laravel Package

eliashaeussler/rector-config

Opinionated, reusable Rector configuration for PHP/Laravel projects. Provides curated rule sets and sensible defaults to quickly add automated refactoring and code upgrades, with easy integration into existing Rector setups.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by requiring the package via Composer in your project:

composer require --dev eliashaeussler/rector-config

Then create or update rector.php in your project root with a single line to include the shared configuration:

return \EliasHaeussler\RectorConfig\Loader\DefaultConfigLoader::load(__DIR__);

That’s it — Rector now runs with sensible defaults including PHP 8.0+ upgrades, null safety improvements, and modern syntax migrations. Run a dry-run first to preview changes:

vendor/bin/rector process src --dry-run

Implementation Patterns

  • Baseline adoption: Use it as a drop-in baseline across microservices or team-owned repos to enforce consistent standards — ideal for monorepos with shared coding standards.
  • Gradual upgrade path: Combine with rector.php extension to enable stricter sets (e.g., php82, code-quality) gradually per release cycle.
  • CI integration: Add a rector job in your GitHub/GitLab CI to auto-refactor or fail if changes are needed:
    - vendor/bin/rector process src --dry-run
    
  • Team onboarding: New developers run rector:process before commits (via pre-commit hook or IDE integration) to automatically adopt current best practices.

Gotchas and Tips

  • Rule conflicts: If you define custom rules, ensure they don’t clash with the included sets — especially around null handling or type widening. Use --debug flag to trace rule interactions.
  • Config precedence: The DefaultConfigLoader merges rules before your project’s local rector.php config; use ->withConfiguredRule() for targeted overrides.
  • PHP version constraints: The package enforces a minimum PHP version (currently 8.1). If your project supports older versions, you may need to selectively disable sets or pin to an older version.
  • Cache behavior: Rector caches results by default — clear it (--clear-cache) when config changes unexpectedly behave inconsistently across runs.
  • Extensibility: Extend DefaultConfigLoader and override methods to inject project-specific paths, custom sets, or exclude patterns — great for complex legacy apps.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport