laravel-command-hooks maintained by regnerisch
Authors
Last update
2023/02/22 09:01
(dev-master)
License
Downloads
1 914
Laravel Command Hooks
This package adds a before and after hook to Laravels command class.
Usage
The methods are only called if they are defined inside you class. If you do not need them, do not implement them.
Returning a none zero value inside you before method will exit the execution immediately. Neither handle/ __invoke
nor the after method will be called.
The after method will get the exit code of the executed handle/ __invoke method, you can manipulate the exit code
inside the after method and overwrite it by returning you own exit code. Returning null or nothing will keep the
original exit code.
use \Regnerisch\LaravelCommandHooks\Command;
class MyCustomCommand extends Command
{
protected function before(): ?int
{
// Do something before the command
return $code;
}
protected function after(int $code): ?int
{
// Do something after the command
return $code;
}
// ...
}