使用 API Guard 和 Laravel

using API Guard with Laravel

您好,我正在 laravel 5.2 中使用此 package

实施密钥验证

它给我一个错误

 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 有什么建议吗?

P.S对不起我的英语不好

错误是在 3.0.3 和 3.1.0 之间引入的,尝试降级到 3.0.3 可能会有帮助。

您也可以尝试更新 Api-gaurd

的最新包

通过将此块添加到 app/config/apiguard.php 文件,在我的构建中修复了此问题。

'providers'            => [
    'auth' => Chrisbjr\ApiGuard\Providers\Auth\Illuminate::class
],