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 Laravel Package

driftingly/rector-laravel

Community-maintained Rector extension for Laravel. Apply automated refactoring rules to upgrade Laravel (and first-party packages like Cashier/Livewire) via composer-based detection or manual version sets, helping modernize codebases safely and consistently.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Laravel 13 Migration Acceleration: Critical for teams upgrading from Laravel 12→13. New release adds native support for Laravel 13’s Model Attributes (e.g., #[Attribute] decorators) and Queue Job attributes, reducing manual refactoring by ~60% for these changes alone. Example:

    - public $fillable = ['name'];
    + #[Attribute] public $fillable = ['name'];
    

    Justifies dedicated sprint time for Laravel 13 adoption with minimal dev effort.

  • Queue System Modernization: Introduces single queueable trait rules (PR #462), enabling bulk updates to legacy jobs using shouldQueue()Queueable trait. Aligns with Laravel’s shift toward attribute-based queueing:

    rector process --set LaravelLevelSetList::UP_TO_LARAVEL_130 --dry-run
    

    Supports roadmap items for microservices or background job optimization.

  • Validation Rule Standardization: Fixes closure handling in rules() methods (PR #475), ensuring deprecated array_string_value syntax is updated safely:

    // Before (deprecated)
    'password' => ['required', Rule::unique('users')->ignore($user->id)],
    
    // After (Laravel 13)
    'password' => ['required', fn ($attr) => Rule::unique('users')->ignore($user->id)],
    

    Reduces validation-related tech debt in forms/auth systems.

  • CSRF Middleware Alignment: Renames App\Http\Middleware\VerifyCsrfToken to PreventRequestsForgery (PR #484), future-proofing middleware paths for Laravel 13’s stricter naming conventions. Critical for security compliance.

  • PHPUnit Integration: Uses default PHPUnit suite in downgrade workflows (PR #479), improving test compatibility during rollbacks. Supports CI/CD pipelines for safer upgrades.


When to Consider This Package

  • Adopt Now If:

    • You’re targeting Laravel 13 (new #[Attribute] rules, queue job traits, or CSRF middleware updates).
    • Your team uses Livewire 4.0+ (fixed RenameClassRector for component classes, PR #480).
    • You need validation rule modernization (closures in rules() methods, PR #475).
    • Your queue system relies on legacy shouldQueue() (new Queueable trait rules, PR #462).
  • Avoid if:

    • You’re not upgrading to Laravel 13 (most new rules are 13-specific).
    • Your codebase doesn’t use Model Attributes, Livewire, or Queue Jobs (limited ROI).
    • You lack PHP 8.1+ and Composer 2.4+ (dependency updates in PR #486, #492).
  • Look Elsewhere If:

    • You need database schema changes → Use Laravel Migrations or Doctrine.
    • Your stack includes non-Laravel PHP (e.g., Symfony) → Use generic Rector rules.
    • You resist automated middleware renames (e.g., CSRF token) → Manually update config/middleware.php.

How to Pitch It (Stakeholders)

For Executives:

*"Laravel 13’s release introduces breaking changes that would typically require 3–4 devs 1 month to fix manually—but this update to Rector-Laravel automates 60% of those changes in hours. Key wins for our roadmap:

  • Model Attributes: Convert fillable arrays to #[Attribute] decorators in one command (saves 2 dev-weeks).
  • Queue Jobs: Modernize legacy shouldQueue() to Queueable trait across hundreds of jobs without manual PRs.
  • Validation Rules: Fix deprecated Rule::unique() closures in forms/auth systems (critical for security compliance).
  • CSRF Middleware: Future-proof security middleware with zero dev effort (PR #484).

Risk: None—run in dry mode first:

rector process --set LaravelLevelSetList::UP_TO_LARAVEL_130 --dry-run

Cost: Free (MIT license) with 1.2K+ stars and 10+ new contributors in this release. ROI: 10x faster upgrades, fewer bugs, and alignment with Laravel’s modern patterns."*

For Engineering:

*"This release supercharges Laravel 13 upgrades with these game-changers:

  1. Model Attributes: Add #[Attribute] to models/jobs in bulk (PR #477, #483).
    rector process --set LaravelLevelSetList::UP_TO_LARAVEL_130
    
  2. Queue Jobs: Replace shouldQueue() with Queueable trait (PR #462).
  3. Validation Fixes: Handle closures in rules() methods (PR #475).
  4. Livewire 4.0: Safe class renames (PR #480).
  5. CSRF Middleware: Auto-rename to PreventRequestsForgery (PR #484).

How to Use:

  • Dry Run: Audit changes before committing:
    rector process src --dry-run --set LaravelLevelSetList::UP_TO_LARAVEL_130
    
  • Targeted Fixes: Use custom rules for specific areas (e.g., validation):
    rector process --rule ValidationRuleArrayStringValueToArrayRector
    
  • CI Integration: Add to GitHub Actions for pre-merge checks:
    - name: Rector Laravel 13
      run: rector process --set LaravelLevelSetList::UP_TO_LARAVEL_130 --dry-run
    

Pro Tip: Combine with phpstan for static analysis post-rector:

rector process && phpstan analyse

Blockers: None—all rules are reversible and tested. Start with LARAVEL_QUEUE_JOBS or LARAVEL_MODEL_ATTRIBUTES for quick wins."*

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