samer-alsayegh/social_plugin

There is no license information available for the latest version (dev-master) of this package.

Add Social Login and Sign Up integration to Laravel Lumen Framework

dev-master 2018-07-20 10:49 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:33:23 UTC


README

This package is a social Login and Sign Up integration based on Laravel/Lumen Framework and laravel/socialite.

So, first to use this library you should install laravel/lumen., and then intall the laravel/socialite.

After you have finished intalling lumen and socialite, then install this library so you are able to authenticate with OAuth providers using Laravel Socialite. Socialite currently supports authentication with Facebook, Twitter, LinkedIn, Google, GitHub and Bitbucket..

In this package you can see the edits I did so that the socialite would work:

  • File bootstrap/app.php

    • Uncomment $app->withFacades();

    • Add the below code in "Create the Application" Section:
      if (!class_exists('Socialite')) { class_alias('Laravel\Socialite\Facades\Socialite', 'Socialite'); }

    • Add the below code in the "Register Service Providers" Section:
      $app->register(Laravel\Socialite\SocialiteServiceProvider::class);

    • Add the below code before the "return $app;"
      $app->configure('services');

  • config/services.php

    • Add folder config at the root of the app

    • Add in folder config file services.php
      This file contains the id, secret, and callback url of each platform used(Facebook, Github, Twitter, etc..)


  • app/Http/Controllers/Auth/LoginController.php

    • Add folder Auth inside app/Http/Controllers

    • Add in folder file LoginController.php
      This file is responsible for the functions that handles the call to the platform and the callback returned to get the userinfo

  • Add file helpers.php inside the app folder

    • Lumen is so stripped down, that the Route resolves to a simple array, rather than a Route object. This is a problem, since the Request::route($key) method assumes the Route will have a parameter method. So this file contains function route_parameter to get the parameters of the route.
      N.B To use the functions in the helpers.php file, you have to add in the composer.json under the autoload "files": [ "app/helpers.php" ] and run in the command line composer dump-autoload