March 15, 2021 By Mitul Patel Category: Laravel Development

It is an open-source PHP framework available free of cost intended for the development of Web Application which follows MVC (Model-View-Controller) architecture. Laravel comes with features as a modular packaging system, a variety of ways to access the relational database, utilities that help in web application deployment. Its licensed under MIT License. The stable version of Laravel was released on September 8, 2020.

What is Socialite?

Socialite is a simple Laravel based technique of authentication with OAuth. Socialite supports authentication with Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, Bitbucket.

Advantage of using Laravel

  • MVC Support and Object-Oriented Approach

    One of the best benefits is that Laravel follows MVC (Model-View-Controller) architectural pattern and has an expressive syntax structure that follows an object-oriented approach.

  • Built-in Authentication & Authorization

    Laravel provides out-of-the-box configuration for implement authentication and authorization mechanism. This mechanism is well equipped with artisan commands to develop a secure application.

  • Packaging System

    Laravel’s package system supports and deals with multiple software systems and libraries, which can help web applications automate the process. Laravel uses Composer as a dependency manager. Packages are the best way to increase the development to provide the functionality that is required.

  • Multiple File System

    Laravel has built-in support for cloud storage systems like Amazon S3, Rack space and supports local storage. Its smooth and simple to switch between local storage and cloud storage – the benefit is that the APIs will remain the same. Such a structure and system help a lot when there is a need for a distributed environment.

  • Eloquent ORM

    Eloquent ORM is Laravel’s built-in ORM. Laravel has the best object-relational mapper as compared to other frameworks. This object-relational mapping allows you to interact with the database of the application using expressive syntax.

  • Task Scheduling

    Laravel has introduced a scheduler from version 5.0. In addition to lined-up artisan commands, it allows programmatic scheduling and execution of tasks periodically. In the internal mechanism, schedular relies on the cron daemon to run the jobs.

Install Socialite Composer

composer require Laravel/socialite

After installation, open config/app.php file and add following line in providers array

add the following line in alias array

Develop Facebook App

Fill your app details like app name, contact email and category

After creating app, in you setting section, you need to fill details like App Domain/s and Website URL where your app is used. I just set them to local host for now

Now we use those App Id and App Secret as CLIENT_ID and CLIENT_SECRET in your app configuration file. We store those details in .env file and reference them in

config/services.php file

Route::get('/facebook/redirect', function ()
return Socialite::driver('facebook')->scopes(['manage_pages','publish_pages'])-

Code Structure

Route::get('/facebook/callback', function ()
$auth_user = Socialite::driver('facebook')->user();

Share with :

Total Ratings 5/5 (1)

Rate Us!

Thanks For Rating Us