When I had to copy Rector configs between Laravel projects, it always felt annoying — and easy to mess up. I wanted a better way.
My approach is simple: if something isn’t tied to a project’s business logic and can be reused, it should live in its own package. This keeps projects clean and makes sharing updates across projects effortless.
Centralizing Rector rules like this means consistent standards and less hassle when managing multiple Laravel apps.
Copying Rector configs between Laravel projects was always a bit annoying — and easy to forget. So I created rector-for-laravel to centralize all my Rector rules in one place.
With this package, I keep a single source of truth for my Laravel Rector config. When I update rules, I update the package — all my projects get those improvements without me having to manually sync configs.
Starting a new project? Just require the package and publish the config using the included Artisan command. No more copy-pasting or guesswork.
• Provides a ready-to-use rector.php
config tailored for Laravel projects
• Adds an Artisan command to publish the config easily
bash
php artisan vendor:publish --tag=rector-config
• Helps maintain consistent code quality across all your Laravel apps
• Saves time and reduces mistakes by centralizing Rector rules
If you work on multiple Laravel projects or freelance, this package can make your life a lot easier.
Once the package is added to a Laravel project, setting up Rector is simple:
1. Run the publish command to get the config file:
php artisan vendor:publish --tag=rector-config
2. Run Rector as usual — the config is ready to go.
Whenever I need to update Rector rules, I just update the package and bump the version in my projects. No more juggling multiple config files or missing updates.
It’s especially handy when juggling several freelance projects — consistent, reliable code checks without extra effort.
Remember how I mentioned I like to pull reusable code out into packages? Here are some of the ones I’ve made. Hopefully, they give you ideas on what you might extract into packages in your own projects — or want to use those in yours too.
• Assertions for Laravel Form Requests in tests
• Generate Laravel HTTP clients code boilerplate
• Keep pagination state on redirects after actions
• Handy assertions for testing Laravel views
• Simple in-app notification system for Laravel
• Extra test assertion helpers for Laravel
• Cleanup old files on Laravel filesystem disks
Check them out if you want inspiration for your own reusable packages!
Extracting reusable code into packages keeps my Laravel projects cleaner and easier to manage. If you work on multiple projects, give it a try — it really helps.
Check out my Rector package and other tools, and feel free to reach out if you want to chat!