Action for small code bits, usable in laravel
vertaalbureau-perfect/action-pattern is a Laravel package for action for small code bits, usable in laravel.
It currently has 0 GitHub stars and 1.259 downloads on Packagist (latest version v0.2.5).
Install it with composer require vertaalbureau-perfect/action-pattern.
Discover more Laravel packages by vertaalbureau-perfect
or browse all Laravel packages to compare alternatives.
Last updated
Actions are meant to be very small, single purpose, bits of code.
Because of the small footprint actions are easy reusable.
Example use cases are:
composer require vertaalbureau-perfect/action-pattern
php artisan make:action [ActionName]
You can also create actions in sub namespaces:
php artisan make:action [SubNamespace]/[ActionName]
Actions are placed in your app/Actions folder.
Imagine a simple action to write something to the log:
class CreateLogAction extends AbstractAction
{
public function handle($message)
{
Log::debug($message);
}
}
And to use it we would simply call:
CreateLogAction::execute('Write me to the log please!');
For Testing purposes you can use the static fake method.
CreateLogAction::fake();
If your code depends on a return value from the action you can provide the return value in the fake method.
CreateLogAction::fake('Log Success');