Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shepparddigital's avatar

Authentication: index not found: provider

I've trying lumen for the first time and I'm attempting to setup authentication.

After following the instructions in the lumen documentation, I see to be getting the following error and I can't figure out what I'm doing wrong;

in AuthManager.php line 152 at Application->Laravel\Lumen\Concerns{closure}('8', 'Undefined index: provider', '/home/webdev/public_html/appdevs/supafanzv2/vendor/illuminate/auth/AuthManager.php', '152', array('name' => 'api', 'config' => array('driver' => 'token'))) in AuthManager.php line 152 at AuthManager->createTokenDriver('api', array('driver' => 'token')) in AuthManager.php line 92 at AuthManager->resolve('api') in AuthManager.php line 70 at AuthManager->guard(null) in Authenticate.php line 38 at Authenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Laravel\Lumen\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in RoutesRequests.php line 621 at Application->sendThroughPipeline(array('App\Http\Middleware\Authenticate'), object(Closure)) in RoutesRequests.php line 382 at Application->dispatch(object(Request)) in RoutesRequests.php line 327 at Application->run(object(Request)) in index.php line 31

I've uncommented the AuthServiceProvider in bootstrap/app.php and left the Authentication middleware unchanged, but of course have uncommented it in the bootstrap/app.php file also

I've setup my database settings in the env file, and create a user table which contains an 'api_key' field to match that required in the AuthServiceProvider->boot() method.

0 likes
3 replies
shepparddigital's avatar

To expand on this, I did find the following in the auth.php configuration file;

return [

'defaults' => [
    'guard' => env('AUTH_GUARD', 'api'),
],

'guards' => [
    'api' => ['driver' => 'token'],
],

'providers' => ['eloquent'
],

'passwords' => [
    //
],

];

However there seems to be no documentation that tells you how to complete the providers section of the above configuration; I'm guessing I need to setup the configuration to tell lumen to use Eloquent as the provider, but I don't know how to.

shepparddigital's avatar

I seem to have resolved this by tracing through the code to determine what lumen was expecting.

I copied the /vendor/laravel/config/ folder to the root of my project, deleted all .php files in the new folder except the auth.php file.

I changed the guards section of the file to;

'guards' => [ 'api' => ['driver' => 'token', 'provider' => 'api'], ],

and the providers section to;

'providers' => [ 'api' => ['driver' => 'eloquent', 'model' => 'App\User'], ],

This seems to resolve the issue. It's a shame this doesn't just work out of the box and that the documentation doesn't seem to tell you that you need to do something like this.

2 likes
maxochmax's avatar

It has always worked fine for me until recently(today) when I did a composer update.

This is not so good for me :( I have to spend lots of time finding this issue. Have exactly the same issue as you.

Bleh. As you said, this issue should not appear. Wierd.

Edit: I could revert back to old composer.lock file. There might be issues in the new auth libs?

Please or to participate in this conversation.