尝试通过流明+ arubacao/http-basic-auth-guard作曲家软件包,将lumen
用于简单轻便的REST API
界面。
我遇到了一个瓶颈问题,即: Argument 2 passed to Arubacao\BasicAuth\BasicGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given,
called in /Applications/MAMP/htdocs/app.mydomain.com/api/vendor/arubacao/http-basic-auth-guard/src/BasicGuardServiceProvider.php on line 38
config / auth.php的内容:
return [
'defaults' => [
'guard' => env('AUTH_GUARD', 'api'),
],
'guards' => [
'api' => [
'driver' => 'basic',
'provider' => 'users'
],
// ...
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class
],
],
'providers' => [
//
],
'passwords' => [
//
],
];
bootstrap / app.php的内容
require_once __DIR__.'/../vendor/autoload.php';
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
$app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../')
);
$app->withFacades();
$app->withEloquent();
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);
$app->register(App\Providers\AuthServiceProvider::class);
$app->register(Arubacao\BasicAuth\BasicGuardServiceProvider::class);
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__.'/../routes/web.php';
});
return $app;
*设置与记录在案的in arubacao/http-basic-auth-guard repo
相同流明版本:5.6.4
答案 0 :(得分:0)
return [
'defaults' => [
'guard' => env('AUTH_GUARD', 'api'),
],
'guards' => [
'api' => [
'driver' => 'basic',
'provider' => 'users'
],
// ...
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class
],
],
// This should be removed, it was leftover from the boiler template of lumen repo.
'providers' => [
//
],