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.
CreateOrder, ProcessPayment).RegisterUser, UpdateProfile).GenerateReport, SendEmail) to queues while keeping logic reusable.CreateInvoice, CancelSubscription)."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."
*"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:
CreatePost works in both web routes and background jobs).Post::create() in isolation without hitting the database).composer require and make:action—no new paradigms.Tradeoffs:
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."*
*"This package lets you replace messy controller methods with clean, reusable actions. Here’s how it works:
php artisan make:action CreateUser
class CreateUser extends Action {
public function __construct(
public string $name,
public string $email
) {}
public function handle() {
User::create($this->data());
}
}
// In a controller
$action = new CreateUser(name: 'John', email: '[email protected]');
$action->handle();
// Or statically
CreateUser::run(name: 'Jane', email: '[email protected]');
Pros:
Try it on a non-critical feature first to see how it feels!"*
How can I help you explore Laravel packages today?