DEV Community


Social login with PHP

mosaxiv profile image mosa ・1 min read

I think that most people will use Socialite when executing social login with Laravel.
By using Socialite, it is very easy to execute social login😘

I would like to use Socialite outside of Laravel! That is what I thought, and I made a library that can be use with other frameworks and pure PHP, with the same execution method.

Github : (Please star😎)

Use(Twitter login)

Please obtain ConsumerKey and ConsumerSecret from Twitter in advance.


composer require socialite-manager/socialite


oath.php :

use Socialite\Socialite;

$config = [
    'client_id' => 'xxx', //ConsumerKey
    'client_secret' => 'xxx', //ConsumerSecret
    'redirect' => '', // Redirect URL

Socialite::driver('twitter', $config)->redirect();

Acquire user information

callback.php :

use Socialite\Socialite;

$config = [
    'client_id' => 'xxx',
    'client_secret' => 'xxx',
    'redirect' => '',

$user = Socialite::driver('twitter', $config)->user();


That's it😎

Use in framework

Have options for use with the framework.

For example CakePHP3

UsersController :

Socialite::driver('twitter', $config)

Please check the documentation for details!

Discussion (0)

Editor guide