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

Action Laravel Package

laraditz/action

Define single-purpose Action classes for Laravel and Lumen to keep code DRY. Generate actions via artisan, pass data through constructor properties, and execute with handle() or a convenient static run() method. Includes a data() helper for all properties.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Modular Business Logic: Enables a cleaner architecture by isolating business logic into reusable actions, reducing controller clutter and improving maintainability. Aligns with Domain-Driven Design (DDD) principles by encapsulating domain-specific workflows (e.g., CreateOrder, ProcessPayment).
  • Developer Velocity: Accelerates development by providing a standardized pattern for handling complex workflows, reducing boilerplate, and improving code consistency. Ideal for teams adopting Laravel best practices or migrating from monolithic controllers.
  • Roadmap Flexibility: Supports future adoption of event-driven architecture or CQRS by treating actions as commands that can later be extended with event listeners or sagas.
  • Build vs. Buy Decision: Buy—justifies adoption if the team lacks time/resources to build a custom action system. Avoids reinventing the wheel while staying within Laravel’s ecosystem.
  • Key Use Cases:
    • Form Handling: Encapsulate validation, authorization, and persistence logic (e.g., RegisterUser, UpdateProfile).
    • Background Jobs: Offload long-running tasks (e.g., GenerateReport, SendEmail) to queues while keeping logic reusable.
    • API Endpoints: Replace bloated controller methods with type-safe, testable actions (e.g., CreateInvoice, CancelSubscription).
    • Testing: Actions are easily mockable, improving test coverage and reliability for critical workflows.

When to Consider This Package

  • Adopt if:
    • Your team struggles with fat controllers or scattered business logic.
    • You’re building a Laravel/Lumen app with complex workflows (e.g., multi-step processes, transactions, or validation-heavy operations).
    • You prioritize DRY principles and want to reduce code duplication across controllers, jobs, and commands.
    • Your roadmap includes modularity (e.g., microservices, DDD, or event-driven architecture).
    • You need a lightweight, zero-config solution with minimal learning curve.
  • Avoid if:
    • Your project is simple CRUD with no need for abstraction (e.g., a small admin panel).
    • You’re already using a mature framework (e.g., Livewire, Inertia.js) that handles logic encapsulation differently.
    • Performance is critical for high-frequency actions (e.g., real-time systems where micro-optimizations matter).
    • Your team lacks experience with DDD or service layers, risking inconsistent adoption.
  • Look Elsewhere if:
    • You need advanced features like middleware support, built-in validation, or action chaining (consider Laravel Nova, Spatie’s Macroable, or custom service containers).
    • Your project requires real-time action execution (e.g., WebSocket triggers) without additional tooling.
    • You’re using Laravel <8.0 or PHP <8.0, as the package drops support for older versions.

How to Pitch It (Stakeholders)

For Executives:

"This package helps us write cleaner, more maintainable code by moving complex logic—like order processing or user registration—out of cluttered controllers and into reusable ‘action’ classes. Think of it like Lego blocks for business logic: developers snap together standardized pieces to build features faster, with fewer bugs. For example, instead of copying-pasting User::create() logic across 10 controllers, we’d encapsulate it in a single CreateUser action. This cuts development time by ~30% for repetitive tasks and makes the codebase easier to scale and test. Since it’s open-source (MIT license) and built for Laravel, there’s no vendor lock-in, and it integrates seamlessly with our existing stack."

For Engineering:

*"This solves the ‘fat controller’ problem by moving logic into self-contained actions with typed properties and a handle() method. Here’s why it’s worth adopting:

  • DRY: Reuse actions across APIs, queues, and commands (e.g., CreatePost works in both web routes and background jobs).
  • Testable: Mock dependencies easily (e.g., test Post::create() in isolation without hitting the database).
  • Scalable: Works with Lumen and Laravel; plays well with queues/jobs.
  • Zero config: Just composer require and make:action—no new paradigms.

Tradeoffs:

  • Slightly more boilerplate for trivial cases (but pays off for any logic >5 lines).
  • No built-in validation or transactions (but you can wrap actions in Laravel’s Validator or DB::transaction()).

Start with high-value workflows (e.g., checkout, user auth) and expand. It’s a low-risk way to adopt cleaner architecture."*

For Developers:

*"This package lets you replace messy controller methods with clean, reusable actions. Here’s how it works:

  1. Generate an action:
    php artisan make:action CreateUser
    
  2. Define inputs and logic:
    class CreateUser extends Action {
        public function __construct(
            public string $name,
            public string $email
        ) {}
        public function handle() {
            User::create($this->data());
        }
    }
    
  3. Use it anywhere:
    // In a controller
    $action = new CreateUser(name: 'John', email: '[email protected]');
    $action->handle();
    
    // Or statically
    CreateUser::run(name: 'Jane', email: '[email protected]');
    

Pros:

  • No more copy-pasted logic—actions are reusable across routes, jobs, and commands.
  • Type-safe (PHP 8.1+ constructor properties).
  • Easy to test (mock dependencies in unit tests). Cons:
  • Not magic: You still need to handle validation/transactions manually (but it’s easier than in controllers).
  • Best for complex logic—simple CRUD can stay in controllers.

Try it on a non-critical feature first to see how it feels!"*

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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle