yep, not possible.
code only runs when there is a request. No request, no code execution.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using 5.3 and I have a listener listening for when a user logs out. The listener is triggered when I log out manually, but not when the session times out or I close the browser.
Here's the set up for the event listening in my EventServiceProvider:
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'Illuminate\Auth\Events\Logout' => [
'App\Listeners\UserLoggedOut',
],
];
And the listener itself:
namespace App\Listeners;
use App\Mail\RegistrationIncomplete;
use Illuminate\Auth\Events\Logout;
use Illuminate\Support\Facades\Mail;
class UserLoggedOut
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param Logout $event
* @return void
*/
public function handle(Logout $event)
{
// if the user hasn't completed registration, send them an email
$user = $event->user;
if ($user->ui_step < 5) {
$incompleteRegistration = new RegistrationIncomplete($user);
Mail::to($user)->send($incompleteRegistration);
}
}
}
Any thoughts?
Please or to participate in this conversation.