regnerisch / laravel-command-hooks
Installs: 1 504
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 2
Open Issues: 0
pkg:composer/regnerisch/laravel-command-hooks
Requires
- illuminate/console: ^9.25
This package is auto-updated.
Last update: 2025-10-22 13:50:46 UTC
README
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; } // ... }