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

Laravel Actions Laravel Package

lorisleiva/laravel-actions

Unify your Laravel app logic into single-purpose “Action” classes that can run as controllers, jobs, listeners, or commands. Keep business logic in one place, reduce duplication, and generate actions via artisan with flexible asX entrypoints.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Architectural Shift from Controllers to Task-Oriented Design: Adopt a domain-driven approach where actions encapsulate single responsibilities (e.g., PublishArticle, ProcessPayment). This aligns with clean architecture principles, reducing controller bloat and improving maintainability.

  • Accelerate Feature Development:

    • Build vs. Buy: Avoid reinventing middleware, validation, or job wrappers. Leverage pre-built decorators (asController, asJob, asCommand) to standardize execution paths.
    • Roadmap: Prioritize modularity—actions can be reused across projects (e.g., SendEmailNotification in both web and CLI contexts).
  • Use Cases:

    • API/Backend Services: Replace controllers with actions for stateless HTTP handlers (e.g., GenerateReport::asController()).
    • Event-Driven Systems: Convert listeners to actions (e.g., SyncUserProfile::asListener()) for decoupled event handling.
    • CLI/Jobs: Unify command logic with background tasks (e.g., BackupDatabase::asCommand() and asJob()).
    • Testing: Auto-generate test stubs for actions (php artisan make:action --test), reducing boilerplate.
  • Performance Optimization:

    • Lazy Execution: Run actions as objects (Action::run()) to avoid framework overhead (e.g., in scheduled tasks).
    • Middleware Reuse: Apply middleware to actions via decorators (e.g., asController() with auth:api).
  • Team Scalability:

    • Onboarding: New devs focus on "what the app does" (actions) rather than Laravel’s ecosystem (controllers, jobs).
    • Ownership: Assign action ownership to feature teams (e.g., PaymentTeam owns ProcessRefund).

When to Consider This Package

  • Adopt When:

    • Your Laravel app has growing controller complexity (e.g., >500 lines in a single controller).
    • You’re building a modular monolith or microservices where reusable logic is critical.
    • Your team struggles with separation of concerns (e.g., mixing validation, business logic, and HTTP responses).
    • You need consistent execution paths across HTTP, CLI, queues, and events.
    • Testing is a bottleneck: Actions auto-generate test stubs and support mocking.
  • Look Elsewhere If:

    • Your app is tiny (<5 controllers) and doesn’t need abstraction.
    • You’re using Laravel Octane heavily—actions may require adjustments for real-time contexts.
    • Your team lacks PHP/OOP maturity to adopt action-based design.
    • You need fine-grained middleware control per route (actions centralize middleware via decorators).
    • You’re not using Laravel 9+ (package drops support for older versions).

How to Pitch It (Stakeholders)

For Executives:

"Laravel Actions lets us build faster and scale cleaner. Instead of writing spaghetti controllers that mix HTTP logic with business rules, we’ll organize code by what the app does—like ProcessOrder, SendInvoice, or SyncData. This reduces technical debt, makes features reusable across projects, and lets our team ship high-quality code 30% faster (based on similar adopters). It’s like upgrading from procedural code to functions—just for Laravel."

Key Outcomes:

  • Faster Hiring: New devs ramp up by learning actions, not Laravel’s ecosystem.
  • Lower Costs: Reuse actions across microservices (e.g., AuthenticateUser in web and API).
  • Future-Proof: Works with Laravel’s latest versions and integrates with queues, events, and CLI.

For Engineering Teams:

*"This package eliminates boilerplate while enforcing clean architecture. No more:

  • Controllers with 20 methods doing unrelated things.
  • Copy-pasted validation logic in jobs and commands.
  • Hard-to-test spaghetti code.

How It Works:

  1. Define an action (e.g., CreateUserSubscription) with a handle() method for core logic.
  2. Decorate it for any execution context:
    // HTTP
    Route::post('/subscribe', CreateUserSubscription::class);
    
    // Queue
    CreateUserSubscription::dispatch($user, $plan);
    
    // Event
    Event::listen(UserUpgraded::class, CreateUserSubscription::class);
    
  3. Reuse everywhere: The same action runs in tests, CLI, or APIs.

Why Now?

  • Laravel 13 ready: Supports the latest framework features.
  • Test-friendly: Auto-generates test stubs and supports mocking.
  • Performance: Run actions as objects for non-HTTP workflows (e.g., scheduled jobs).

Migration Path: Start with new features—create actions for critical paths (e.g., payments, user flows). Gradually refactor legacy controllers into actions.

Risk Mitigation:

  • Backward Compatible: Actions work alongside existing controllers.
  • Documented: laravelactions.com has migration guides.
  • Community: 2.8K+ stars, active maintenance (last release: 2026)."*
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai