mardi 26 mai 2020

Why is 'Illuminate\Auth\SessionGuard' does not have a method 'driver' error coming after Laravel update from 5.1 to 5.2?

I updated a very old Laravel project form 5.1 to 5.2. When I'm testing my app this error occurred 'Illuminate\Auth\SessionGuard' does not have a method 'driver'. No idea what's happening here.

I tried to get the backtrace. It looks like its triggered from AuthServiceProvider but that doesn't help much.

I'll post the backtrace, auth config, and the service provider.

Backtrace

array:3 [
    0 => "Illuminate\Auth\SessionGuard"
    1 => "driver"
    2 => array:11 [
      0 => array:2 [
        0 => "/vagrant/app/Providers/AuthServiceProvider.php"
        1 => 32
      ]
      1 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 731
      ]
      2 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 629
      ]
      3 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
        1 => 697
      ]
      4 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 849
      ]
      5 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 804
      ]
      6 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 774
      ]
      7 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 629
      ]
      8 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
        1 => 697
      ]
      9 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php"
        1 => 152
      ]
      10 => array:2 [
        0 => "/vagrant/public/index.php"
        1 => 57
      ]
    ]
  ]

config/app.php

<?php

  return [

      /*
      |--------------------------------------------------------------------------
      | Authentication Defaults
      |--------------------------------------------------------------------------
      |
      | This option controls the default authentication "guard" and password
      | reset options for your application. You may change these defaults
      | as required, but they're a perfect start for most applications.
      |
      */

      'defaults' => [
          'guard' => 'web',
          'passwords' => 'users',
      ],

      /*
      |--------------------------------------------------------------------------
      | Authentication Guards
      |--------------------------------------------------------------------------
      |
      | Next, you may define every authentication guard for your application.
      | Of course, a great default configuration has been defined for you
      | here which uses session storage and the Eloquent user provider.
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | Supported: "session", "token"
      |
      */

      'guards' => [
          'web' => [
              'driver' => 'session',
              'provider' => 'users',
          ],

          'api' => [
              'driver' => 'session',
              'provider' => 'users',
          ],
      ],

      /*
      |--------------------------------------------------------------------------
      | User Providers
      |--------------------------------------------------------------------------
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | If you have multiple user tables or models you may configure multiple
      | sources which represent each model / table. These sources may then
      | be assigned to any extra authentication guards you have defined.
      |
      | Supported: "database", "eloquent"
      |
      */

      'providers' => [
          'users' => [
              'driver' => 'eloquent',
              'model' => Models\UserModel::class,
          ],

          // 'users' => [
          //     'driver' => 'database',
          //     'table' => 'users',
          // ],
      ],

      /*
      |--------------------------------------------------------------------------
      | Resetting Passwords
      |--------------------------------------------------------------------------
      |
      | Here you may set the options for resetting passwords including the view
      | that is your password reset e-mail. You may also set the name of the
      | table that maintains all of the reset tokens for your application.
      |
      | You may specify multiple password reset configurations if you have more
      | than one user table or model in the application and you want to have
      | separate password reset settings based on the specific user types.
      |
      | The expire time is the number of minutes that the reset token should be
      | considered valid. This security feature keeps tokens short-lived so
      | they have less time to be guessed. You may change this as needed.
      |
      */

      'password' => [
          'email' => 'emails.auth.reminder',
          'table' => 'password_reminders',
          'expire' => 60,
      ],
  ];

AuthServiceProvider::registerAuthenticator()

protected function registerAuthenticator()
{
    $this->app->singleton('auth', function ($app) {
        // Once the authentication service has actually been requested by the developer
        // we will set a variable in the application indicating such. This helps us
        // know that we need to set any queued cookies in the after event later.
        $app['auth.loaded'] = true;

        return new AuthManager($app);
    });

    $this->app->singleton('auth.driver', function ($app) {
        return $app['auth']->driver();
    });
}

Any idea what's the issue?

Thank you.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ccBjcZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire