- How do I install driftingly/rector-laravel for Laravel 13+ upgrades?
- Run `composer require --dev driftingly/rector-laravel` to install it as a dev dependency. Ensure you have Rector installed (`composer require --dev rector/rector`). The package integrates seamlessly with Laravel’s composer.json for version detection.
- Can I use this package to upgrade from Laravel 10 to 13 without manual refactoring?
- Yes, use `LaravelLevelSetList::UP_TO_LARAVEL_130` in your Rector config. This set includes all incremental rules needed for upgrades from Laravel 10/11/12 to 13, ensuring compatibility at each step.
- What Laravel 13-specific rules does this package include?
- The package includes rules for Model Attributes (e.g., `$casts`, `$attributes`), Queue Job attributes (`@onQueue`), and middleware renaming (e.g., `PreventRequestForgery`). These align with Laravel 13’s latest syntax and best practices.
- How does composer-based detection work for Laravel versions?
- Use `LaravelSetProvider::class` in your Rector config with `withComposerBased(laravel: true)`. The package reads your `composer.json` to auto-detect your Laravel version and apply the correct rule set.
- Will this package break my existing Livewire 3.x code if I upgrade to Laravel 13?
- No, but you may need to manually select `LaravelLevelSetList::UP_TO_LARAVEL_130` to ensure Livewire 4.0 compatibility rules are applied. The package includes fixes for Livewire 4.0’s associative array handling.
- How do I test Rector rules before applying them to my production code?
- Run Rector with the `--dry-run` flag to preview changes without modifying files. Example: `rector process --dry-run`. Always test in a staging environment or CI pipeline before production deployment.
- Are there any risks of false positives when using Laravel 13 rules on older Laravel versions?
- Yes, Laravel 13-specific rules (e.g., Model Attributes) won’t apply to pre-Laravel 13 codebases unless explicitly configured. Use `UP_TO_LARAVEL_130` for incremental upgrades to avoid unintended rule application.
- Does this package support custom Laravel attributes or third-party packages beyond Cashier/Livewire?
- The package focuses on Laravel’s first-party packages (Cashier, Livewire) and core framework upgrades. For custom attributes or non-Laravel ORMs, manual rule configuration or forking may be required.
- How can I integrate this with Laravel Pint for consistent code formatting?
- Run Rector first to modernize your code, then use Laravel Pint with the `LARAVEL_CODE_QUALITY` preset. This ensures your code is both syntactically modern and consistently formatted.
- What should I do if a Rector rule fails during a Laravel upgrade?
- Check the error logs and use `--dry-run` to isolate the issue. For complex cases, manually review the rule’s documentation or disable it in your Rector config. Report issues to the GitHub repository for community support.