From 1aba8d968adb470703ef09f31e16e8177f2bca4c Mon Sep 17 00:00:00 2001 From: Jamie Bradley Date: Thu, 11 Apr 2024 11:32:07 +0100 Subject: [PATCH] Documentation Update for Laravel 11 I found that the EventServiceProvider is no longer used in Laravel 11. This commit introdues a section to inform Laravel 11 users of the alternative approach to registering the LogoutDiscourseUser listener against the Logout event. --- readme.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/readme.md b/readme.md index 8633c73..8c1ef7f 100644 --- a/readme.md +++ b/readme.md @@ -192,6 +192,25 @@ When a Laravel `User` logs out, to log out their Discourse session Simply add th ]; ``` +### Laravel 11 + +In Laravel 11, the use of the `EventServiceProvider` is discouraged and events [should be registered in the `AppServiceProvider`](https://laravel.com/docs/11.x/events#manually-registering-events). + +Therefore, the implementation is slightly different, and it should be registered within the `boot` method of the `AppServiceProvider` as per the example below. + +```php + /** + * Bootstrap any application services. + */ + public function boot(): void + { + Event::listen( + \Illuminate\Auth\Events\Logout::class, + \Spinen\Discourse\Listeners\LogoutDiscourseUser::class + ); + } +``` + ## Left to do * badges for user