您好我是使用此package
在laravel 5.2中实现密钥身份验证它给了我一个错误
ErrorException in ApiGuardAuth.php line 14:
Argument 1 passed to Chrisbjr\ApiGuard\ApiGuardAuth::__construct() must be an instance of Chrisbjr\ApiGuard\Contracts\Providers\Auth, null given, called in E:\xammp\htdocs\vox\didww\vendor\chrisbjr\api-guard\src\Providers\ApiGuardServiceProvider.php on line 49 and defined
这是我的控制器
<?php
namespace App\Http\Controllers;
use Chrisbjr\ApiGuard\Models;
use Chrisbjr\ApiGuard\Http\Controllers\ApiGuardController;
class BooksController extends ApiGuardController
{
public function all()
{
return "die";
$books = \App\User::all();
return $this->response->withCollection($books, new BookTransformer);
}
public function show($id)
{
try {
$book = \App\User::findOrFail($id);
return $this->response->withItem($book, new BookTransformer);
} catch (ModelNotFoundException $e) {
return $this->response->errorNotFound();
}
}
}
我还更新了app.php和kernal.php 有什么建议吗?
对不起我的英文不好答案 0 :(得分:3)
错误是在3.0.3和3.1.0之间引入的,尝试降级到3.0.3可能会有所帮助。
你也可以尝试更新最新的Api-gaurd包
答案 1 :(得分:0)
通过将此块添加到app/config/apiguard.php
文件,修复了我的构建问题。
'providers' => [
'auth' => Chrisbjr\ApiGuard\Providers\Auth\Illuminate::class
],