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 Laravel

Rector Laravel Laravel Package

rector/rector-laravel

Community Rector extension to automate Laravel upgrades. Adds Laravel and first-party package rules (e.g., Cashier, Livewire), with version-based set providers that detect your composer.json or manual level sets to apply the right refactors for your target Laravel version.

View on GitHub
Deep Wiki
Context7

Rector upgrades rules for Laravel Framework

Frequently asked questions about Rector Laravel
How do I install `rector/rector-laravel` for Laravel upgrades?
Run `composer require --dev driftingly/rector-laravel` to install the package as a dev dependency. It integrates with Rector, so ensure you have Rector (v0.16+) installed first. The package auto-detects your Laravel version from `composer.json` for version-specific rules.
Can I use this to upgrade from Laravel 9 to 13 without manual code changes?
Yes, use the `UP_TO_LARAVEL_130` set in your Rector config. This set includes all incremental rules needed for the upgrade. Always run a dry run (`--dry-run`) first to preview changes and test critical paths like Eloquent queries or Facade usage.
Does this package support Livewire or Cashier-specific refactoring rules?
Yes, the package includes first-party package rules for Livewire and Cashier. These are included in version-specific sets (e.g., `UP_TO_LARAVEL_130`) and can be applied alongside Laravel core rules. Check the [Rector Find Rule](https://getrector.com/find-rule?activeRectorSetGroup=laravel) page for specifics.
How do I configure Rector to auto-detect my Laravel version?
Use `LaravelSetProvider` in your Rector config and enable `withComposerBased(laravel: true)`. This reads your `composer.json` to apply the correct version-specific rules automatically. Example: `->withSetProviders(LaravelSetProvider::class)->withComposerBased(laravel: true)`.
Will this break my existing Laravel application if I run it without a dry run?
Some rules may alter runtime behavior (e.g., `ResponseHelperCallToJsonResponseRector`), so always use `--dry-run` first. The package is designed for safe refactoring, but critical paths like authentication (Cashier) or routing should be tested post-transformation. Rollback plans should be in place for CI/CD pipelines.
Can I use this with Laravel 8.x or only newer versions?
The package supports Laravel 8+ and requires PHP 8.1+. For Laravel 8.x, use sets like `UP_TO_LARAVEL_90` or `UP_TO_LARAVEL_100`. Newer Laravel versions (11+) will need corresponding sets (e.g., `UP_TO_LARAVEL_130`). Check the [LaravelLevelSetList](https://github.com/driftingly/rector-laravel/blob/main/docs/rector_rules_overview.md) for version compatibility.
How do I handle custom namespace mappings for rules like `RouteActionCallableRector`?
Custom namespace mappings are configured in your Rector config under `importNamespaces` or `importShortClasses`. For example, add `->withImportNamespaces(['App\Http\Controllers' => '\app\Http\Controllers'])` to map your app’s namespace. The package provides defaults, but multi-namespace projects may need adjustments.
Should I run Rector in CI/CD or locally for Laravel upgrades?
Run Rector in CI/CD pipelines for automated upgrades, but start with a dry run (`--dry-run`) to validate changes. For local development, use it in pre-commit hooks or manually in PR reviews. Failed transformations should trigger rollbacks or manual review, depending on risk tolerance.
Are there automated tests to verify rule correctness after transformations?
The package includes tests for rule correctness, but you should also test your application post-transformation. Focus on critical paths like Eloquent models, API routes, and Livewire components. Use PHPUnit or Pest to validate behavior changes. Edge cases (e.g., third-party packages using deprecated Laravel patterns) may require manual testing.
What’s the difference between `LARAVEL_CODE_QUALITY` and `UP_TO_LARAVEL_130` sets?
`LARAVEL_CODE_QUALITY` applies non-breaking refactors like type declarations, stricter collections, or dead code removal. It’s safe for incremental adoption. `UP_TO_LARAVEL_130` includes version-specific rules for upgrading from older Laravel versions (e.g., 9→13) and may include breaking changes. Use `LARAVEL_CODE_QUALITY` first for low-risk improvements.
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.
headercat/phpstan-extension-ide-helper
yosymfony/parser-utils
innmind/black-box
babenkoivan/elastic-migrations
babenkoivan/elastic-adapter
sandermuller/package-boost-php
sandermuller/boost-core
depa/sulu-google-reviews-bundle
croct/plug-symfony
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard