Laravel 5.5 tutorial for beginners : this lesson will show you how to create login or register with facebook in laravel 5.5 apps using socialite package.
at the previews lesson, we have create simple login with twitter using socialite, just open this link Laravel 5.5 login with Twitter
Video Tutorial Socialite Login with Facebook
Video Tutorial Laravel 5.5 Socialite Login with Twitter
Setting up Facebook App
First step you need to create new Facebook app, just follow this link developers.facebook.com
Then, create your first facebook login app.
Adding Services Laravel Project
Next, add facebook services to our services in config/services.php file
Laravel 5.5 tutorial for beginners : this lesson will show you how to create login or register with facebook in laravel 5.5 apps using socialite package.
at the previews lesson, we have create simple login with twitter using socialite, just open this link Laravel 5.5 login with Twitter
Video Tutorial Socialite Login with Facebook
Video Tutorial Laravel 5.5 Socialite Login with Twitter
Setting up Facebook App
First step you need to create new Facebook app, just follow this link developers.facebook.com
Then, create your first facebook login app.
Adding Services Laravel Project
Next, add facebook services to our services in config/services.php file
Laravel 5.5 tutorial for beginners : this lesson will show you how to create login or register with facebook in laravel 5.5 apps using socialite package.
at the previews lesson, we have create simple login with twitter using socialite, just open this link Laravel 5.5 login with Twitter
Video Tutorial Socialite Login with Facebook
Video Tutorial Laravel 5.5 Socialite Login with Twitter
Setting up Facebook App
First step you need to create new Facebook app, just follow this link developers.facebook.com
Then, create your first facebook login app.
Adding Services Laravel Project
Next, add facebook services to our services in config/services.php file
Laravel 5.5 tutorial for beginners, this lesson will show you how to create simple login or register with social media like twitter, facebook, Google, Github, Linkedin etc using socialite package in Laravel 5.5.
Video Tutorial Laravel 5.5 Socialite Login with Twitter
Create Project Socialite Login/Register with Twitter
Create Database and setup connection to the Laravel prjoect.
next we need to use Laravel Authentication, please run this artisan command,
php artisan make:auth
Next, run Laravel migration
php artisan migrate
There are many different sites and packages which you can integrate on your site to provide social login functionality. Laravel has released its own package name Socialite which you can use in your projects. Currently socialite support following social logins:
Facebook
Twitter
LinkedIn
Github
Google
Installing and Setting Up Socialite
Now in your laravel project run the following command to install Laravel Socialite.
composer require laravel/socialite
Once the package is installed open 'app/config.php' file and add the following line in providers array.
Now Socialite is setup in your app. Let’s now handle our Login controller to handle social login request.
Modifying LoginController
In this tutorial I am keeping in mind that you have created an auth system using laravel auth command. Now open ‘app/Http/Controllers/Auth/LoginController.php’ file. Now add the following methods in it.
<?php
namespace AppHttpControllersAuth;
use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;
use Socialite;
use AppUser;
use Auth;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function socialLogin($social) {
return Socialite::driver($social)->redirect();
}
public function handleProviderCallback($social){
$userSocial = Socialite::driver($social)->user();
$user = User::where(['email' => $userSocial->getEmail()])->first();
if ($user) {
Auth::login($user);
return redirect()->action('HomeController@index');
} else {
return view('auth.register', ['name' => $userSocial->getName(),'email'=> $userSocial->getEmail()]);
}
}
}
Creating Routes for Social Login in Laravel
Now open routes/web.php file and add the following routes in it.
For social login buttons I am going to use Social Buttons for bootstrap. Now open resources/views/auth/login.blade.php and add a following div in form after csrf field.
In register page we need to do two things. First we need to add Social Login Buttons and second we need to handle the user data comes from social logged in. First add the following div after csrf field.
Laravel 5.5 tutorial for beginners, this lesson will show you how to create simple login or register with social media like twitter, facebook, Google, Github, Linkedin etc using socialite package in Laravel 5.5.
Video Tutorial Laravel 5.5 Socialite Login with Twitter
Create Project Socialite Login/Register with Twitter
Create Database and setup connection to the Laravel prjoect.
next we need to use Laravel Authentication, please run this artisan command,
php artisan make:auth
Next, run Laravel migration
php artisan migrate
There are many different sites and packages which you can integrate on your site to provide social login functionality. Laravel has released its own package name Socialite which you can use in your projects. Currently socialite support following social logins:
Facebook
Twitter
LinkedIn
Github
Google
Installing and Setting Up Socialite
Now in your laravel project run the following command to install Laravel Socialite.
composer require laravel/socialite
Once the package is installed open 'app/config.php' file and add the following line in providers array.
Now Socialite is setup in your app. Let’s now handle our Login controller to handle social login request.
Modifying LoginController
In this tutorial I am keeping in mind that you have created an auth system using laravel auth command. Now open ‘app/Http/Controllers/Auth/LoginController.php’ file. Now add the following methods in it.
<?php
namespace AppHttpControllersAuth;
use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;
use Socialite;
use AppUser;
use Auth;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function socialLogin($social) {
return Socialite::driver($social)->redirect();
}
public function handleProviderCallback($social){
$userSocial = Socialite::driver($social)->user();
$user = User::where(['email' => $userSocial->getEmail()])->first();
if ($user) {
Auth::login($user);
return redirect()->action('HomeController@index');
} else {
return view('auth.register', ['name' => $userSocial->getName(),'email'=> $userSocial->getEmail()]);
}
}
}
Creating Routes for Social Login in Laravel
Now open routes/web.php file and add the following routes in it.
For social login buttons I am going to use Social Buttons for bootstrap. Now open resources/views/auth/login.blade.php and add a following div in form after csrf field.
In register page we need to do two things. First we need to add Social Login Buttons and second we need to handle the user data comes from social logged in. First add the following div after csrf field.
Laravel 5.5 tutorial for beginners, this lesson will show you how to create simple login or register with social media like twitter, facebook, Google, Github, Linkedin etc using socialite package in Laravel 5.5.
Video Tutorial Laravel 5.5 Socialite Login with Twitter
Create Project Socialite Login/Register with Twitter
Create Database and setup connection to the Laravel prjoect.
next we need to use Laravel Authentication, please run this artisan command,
php artisan make:auth
Next, run Laravel migration
php artisan migrate
There are many different sites and packages which you can integrate on your site to provide social login functionality. Laravel has released its own package name Socialite which you can use in your projects. Currently socialite support following social logins:
Facebook
Twitter
LinkedIn
Github
Google
Installing and Setting Up Socialite
Now in your laravel project run the following command to install Laravel Socialite.
composer require laravel/socialite
Once the package is installed open 'app/config.php' file and add the following line in providers array.
Now Socialite is setup in your app. Let’s now handle our Login controller to handle social login request.
Modifying LoginController
In this tutorial I am keeping in mind that you have created an auth system using laravel auth command. Now open ‘app/Http/Controllers/Auth/LoginController.php’ file. Now add the following methods in it.
<?php
namespace AppHttpControllersAuth;
use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;
use Socialite;
use AppUser;
use Auth;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function socialLogin($social) {
return Socialite::driver($social)->redirect();
}
public function handleProviderCallback($social){
$userSocial = Socialite::driver($social)->user();
$user = User::where(['email' => $userSocial->getEmail()])->first();
if ($user) {
Auth::login($user);
return redirect()->action('HomeController@index');
} else {
return view('auth.register', ['name' => $userSocial->getName(),'email'=> $userSocial->getEmail()]);
}
}
}
Creating Routes for Social Login in Laravel
Now open routes/web.php file and add the following routes in it.
For social login buttons I am going to use Social Buttons for bootstrap. Now open resources/views/auth/login.blade.php and add a following div in form after csrf field.
In register page we need to do two things. First we need to add Social Login Buttons and second we need to handle the user data comes from social logged in. First add the following div after csrf field.