title: Facebook Socialite login with Laravel 5.1
body: <p>I have followed all the step in <a href="http://laravel.com/docs/5.1/authentication" rel="noreferrer">http://laravel.com/docs/5.1/authentication</a> to make the social login with facebook on Laravel 5.1.</p>
  
  <p>Here the steps that I've followed:</p>
  
  <p>1 - Use the command in my Laravel root project:</p>
  
  <pre><code>composer require laravel/socialite
  </code></pre>
  
  <p>2 - register the Laravel\Socialite\SocialiteServiceProvider in your config/app.php configuration file:</p>
  
  <pre><code>'providers' =&gt; [
      // Other service providers...
  
      Laravel\Socialite\SocialiteServiceProvider::class,
  ],
  </code></pre>
  
  <p>3 - Add the Socialite facade to the aliases array in your app configuration file:</p>
  
  <pre><code>'Socialite' =&gt; Laravel\Socialite\Facades\Socialite::class,
  </code></pre>
  
  <p>4 - add the facebook services in config/services.php:</p>
  
  <pre><code> 'facebook' =&gt; [
          'client_id' =&gt; env('FACEBOOK_CLIENT_ID'),
          'client_secret' =&gt; env('FACEBOOK_CLIENT_SECRET'),
          'redirect' =&gt; 'http://homestead.app/auth/facebook/callback',
      ],
  </code></pre>
  
  <p>5 - add to my AuthController.php the methods redirectToProvider() and handleProviderCallback():</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Auth;
  
  use App\User;
  use Validator;
  use App\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\ThrottlesLogins;
  use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  use Socialite;
  
  class AuthController extends Controller
  {
      /*
      |--------------------------------------------------------------------------
      | Registration &amp; Login Controller
      |--------------------------------------------------------------------------
      |
      | This controller handles the registration of new users, as well as the
      | authentication of existing users. By default, this controller uses
      | a simple trait to add these behaviors. Why don't you explore it?
      |
      */
  
      use AuthenticatesAndRegistersUsers, ThrottlesLogins;
  
      /**
       * Redirect path after successful login
       *
       * @var string
       */
      protected $redirectPath = '/greeting';
  
      /**
       * Redirect path after failed login
       *
       * @var string
       */
      protected $loginPath = '/auth/login';
  
      /**
       * Create a new authentication controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          $this-&gt;middleware('guest', ['except' =&gt; 'getLogout']);
      }
  
      /**
       * Get a validator for an incoming registration request.
       *
       * @param  array  $data
       * @return \Illuminate\Contracts\Validation\Validator
       */
      protected function validator(array $data)
      {
          return Validator::make($data, [
              'name' =&gt; 'required|max:255',
              'email' =&gt; 'required|email|max:255|unique:users',
              'password' =&gt; 'required|confirmed|min:6',
          ]);
      }
  
      /**
       * Create a new user instance after a valid registration.
       *
       * @param  array  $data
       * @return User
       */
      protected function create(array $data)
      {
          return User::create([
              'name' =&gt; $data['name'],
              'email' =&gt; $data['email'],
              'password' =&gt; bcrypt($data['password']),
          ]);
      }
  
      /**
       * Redirect the user to the Facebook authentication page.
       *
       * @return Response
       */
  
  
      public function redirectToProvider()
      {
          return Socialite::driver('facebook')-&gt;redirect();
      }
  
      /**
       * Obtain the user information from Facebook.
       *
       * @return Response
       */
      public function handleProviderCallback()
      {
          $user = Socialite::driver('facebook')-&gt;user();
  
          dd($user);
      }
  }
  </code></pre>
  
  <p>I want to highlight that I have created AuthController.php in the folder app/Http/Controllers/Auth/ because after it asks to create the routes: 'Auth\AuthController@redirectToProvider'
  'Auth\AuthController@handleProviderCallback'</p>
  
  <p>6 -  I've added the routes:</p>
  
  <pre><code>Route::get('auth/facebook', 'Auth\AuthController@redirectToProvider');
  Route::get('auth/facebook/callback', 'Auth\AuthController@handleProviderCallback');
  </code></pre>
  
  <p>Now, when I click "Login with facebook" in my login page it goes to <a href="http://homestead.app/auth/facebook" rel="noreferrer">http://homestead.app/auth/facebook</a> and get me the following error:</p>
  
  <blockquote>
    <p>FatalErrorException in AuthController.php line 90: Class 'Socialite'
    not found</p>
  </blockquote>
  
  <p>I have tried to follow the codeanchor <a href="http://www.codeanchor.net/blog/complete-laravel-socialite-tutorial/" rel="noreferrer">guide</a> but it is for laravel 5.0 (I need to use that on laravel 5.1)</p>