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

Single action class for Laravel and Lumen to keep your application DRY

Frequently asked questions about Action
How do I generate an Action class in Laravel using laraditz/action?
Run `php artisan make:action [ActionName]` to generate a new Action class in the `app/Actions/` directory. The generated file includes a constructor and `handle()` method, ready for customization with your business logic.
Can I use this package with Laravel 9, 10, 11, 12, or 13?
Yes, laraditz/action supports Laravel 9 through 13. Ensure your project meets the PHP 8.2+ requirement for full compatibility. The package follows Laravel’s versioning closely for seamless integration.
Does laraditz/action support dependency injection for services like Mailer or Repository?
Absolutely. Type-hint services in the `handle()` method (e.g., `Mailer $mailer`), and Laravel’s service container will automatically inject them. This works the same way as controller method injection.
How do I run an Action class statically vs. instantiating it manually?
Use `ActionClass::run(arg1: value1)` for static execution, or instantiate first (`new ActionClass(arg1: value1)`) and call `->run()`. Both methods are equivalent and leverage constructor property promotion for clean syntax.
Will this package work with Lumen, or is it Laravel-only?
laraditz/action is fully compatible with Lumen. It leverages Laravel’s service container patterns, which Lumen also supports, making it ideal for lightweight APIs or microservices built on either framework.
How do I test an Action class in isolation?
Actions are designed for unit testing. Mock dependencies in your test’s `handle()` method or use Laravel’s service container bindings. Since actions are stateless, you can test them without controllers or middleware.
Does this package handle validation or transactions automatically?
No, laraditz/action is minimalist. For validation, manually use Laravel’s `FormRequest` or `Validator` in `handle()`. For transactions, wrap multi-step logic in `DB::transaction()` or use Laravel’s `QueuedClosure` for queued actions.
Can I queue an Action class for delayed execution?
Yes, implement Laravel’s `ShouldQueue` interface in your Action class. The package supports queuing out of the box, allowing you to dispatch actions to queues like `database`, `redis`, or `sync` for async processing.
What’s the performance impact of using Actions vs. controllers?
The performance impact is negligible for most use cases. Actions reduce boilerplate and improve readability without adding overhead. For high-frequency operations, the abstraction is minimal, but avoid overusing it for trivial logic.
Are there alternatives to laraditz/action for Laravel actions?
Yes, alternatives include `spatie/laravel-action` (more feature-rich, with validation and middleware support) or `laravel-ide-helper`-compatible packages like `orchid/console`. laraditz/action stands out for its simplicity and zero-config setup.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata