Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hook into laravel 4 artisan command

Is there a way to hook into an artisan command easily? What I'm looking to accomplish is have a piece of code executed everytime the php artisan migrate command is executed.

like image 398
veilig Avatar asked Mar 11 '26 08:03

veilig


1 Answers

Just add a listener some place in your code (even at the top of app/start/artisan.php) to listen for the 'artisan.start' event.

Event::listen('artisan.start', function($app)
{
    // $app is instance of Illuminate\Console\Application
    // since the $app hasn't figured the command yet you'll
    // have to do it yourself to check if it's the migrate command
});
like image 134
Chuck Heintzelman Avatar answered Mar 13 '26 22:03

Chuck Heintzelman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!