I try to use the package LaravelSocialite in my system in Lumen (5.1)
I added this in the configservices.php
file :
<?php
//Socialite
'facebook' => [
'client_id' => '##################',
'client_secret' => '##################',
'redirect' => 'http://local.dev/admin/facebook/callback',
],
In bootstrapapp.php
file :
class_alias(LaravelSocialiteFacadesSocialite::class, 'Socialite');
$app->register(LaravelSocialiteSocialiteServiceProvider::class);
Then I created a controller for the facebook authentication :
<?php
namespace AppHttpControllersFacebook;
use AppHttpControllersController;
use LaravelSocialiteContractsFactory as Socialite;
class FacebookController extends Controller
{
public function redirectToProviderAdmin()
{
return Socialite::driver('facebook')->scopes(['manage_pages', 'publish_actions'])->redirect();
}
public function handleProviderCallbackAdmin()
{
$user = Socialite::driver('facebook')->user();
}
}
And in the routes.php
:
$app->get('/admin/facebook/login', 'AppHttpControllersFacebookFacebookController@redirectToProviderAdmin');
$app->get('/admin/facebook/callback', 'AppHttpControllersFacebookFacebookController@handleProviderCallbackAdmin');
I just followed the documentation, changing according to my needs. When I go to page http://local.dev/admin/facebook/login
, I get the following error :
Non-static method LaravelSocialiteContractsFactory::driver() cannot be called statically, assuming $this from incompatible context
Indeed, according to the code, driver function must be instanciate.
EDIT : And if I try to instanciate this class, I get the following error :
Cannot instantiate interface LaravelSocialiteContractsFactory
How do you make this module to work?
See Question&Answers more detail:os