SocialiteProviders / Providers

A Collection of Providers for Laravel Socialite
https://socialiteproviders.com
MIT License
488 stars 436 forks source link

Docs on how to use `SocialiteWasCalled[]` in Laravel 11 #1176

Open binaryfire opened 3 months ago

binaryfire commented 3 months ago

Hi guys

I've just started a new Laravel 11 project and there's no longer an EventServiceProvider. What's the best way to use SocialiteWasCalled[] now? The current format doesn't work inside Event::listen().

Thanks!

m3ntorinho commented 3 months ago
namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;

use \SocialiteProviders\Steam\Provider as SteamProvider;
use \SocialiteProviders\Discord\Provider as DiscordProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
            $event->extendSocialite('steam',SteamProvider::class);
            $event->extendSocialite('discord',DiscordProvider::class);
        });
        //
    }
}

Working fine.

atymic commented 3 months ago

Is Event::listen backwards compatible with older versions? If so, we can just update the docs to cover that.

binaryfire commented 3 months ago

@M4TSKI Thanks! My point was that wasn't documented anywhere. I've never seen that syntax before.

@atymic Thanks for updating the docs.