laravel / tinker

Powerful REPL for the Laravel framework.
https://laravel.com/docs/artisan#tinker
MIT License
7.32k stars 130 forks source link

[2.x] Add after loop callback to Tinker #112

Closed paras-malhotra closed 3 years ago

paras-malhotra commented 3 years ago

Resubmission of https://github.com/laravel/tinker/pull/101 and https://github.com/laravel/tinker/pull/103

This PR enables third party packages like Telescope to register after callbacks that get fired after each execution of a command in the Tinker shell. This will enable packages like Telescope to simulate an application shutdown. Right now Telescope is unable to record events that happen in the Tinker shell because of the inability to simulate such a shutdown.

We can register Tinker after-callbacks now by adding the following code to the boot method of the app or package Service Provider:

public function boot()
{
    $this->callAfterResolving(Shell::class, function (Shell $shell) {
        $shell->addLoopListener(...);
    });
}