ReflectionException:文件中不存在类Tymon \ JWTAuth \ Http \ Middleware \ Authenticate

时间:2018-11-17 14:15:23

标签: php laravel jwt

我正在尝试使用令牌(在邮递员中)获取用户详细信息。但是我遇到了错误:

ReflectionException: Class Tymon\JWTAuth\Http\Middleware\Authenticate does not exist in file C:\xampp\htdocs\sistema\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 779

enter image description here

我的应用程序\ Http \ Kernel.php

protected $routeMiddleware= [
    ...
    'auth.jwt' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class,
    ...
];

我的config \ app.php

'providers' => [
    ...
    Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
    Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
    ...
 ],

我的项目github:https://github.com/vika0/project

1 个答案:

答案 0 :(得分:0)

我修改了我放置的其他文件:

您需要这样做,因为此错误已在developer分支中修复,但尚未在master分支中修复,因此请更改插件。

composer require tymon/jwt-auth:dev-develop --prefer-source

app / Http / Kernel.php(代替那里的

    'auth.jwt' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class

config / jwt.php

  'jwt' => 'Tymon\JWTAuth\Providers\JWT\Namshi',

    /*
    |--------------------------------------------------------------------------
    | Authentication Provider
    |--------------------------------------------------------------------------
    |
    | Specify the provider that is used to authenticate users.
    |
    */

    'auth' => 'Tymon\JWTAuth\Providers\Auth\Illuminate',

    /*
    |--------------------------------------------------------------------------
    | Storage Provider
    |--------------------------------------------------------------------------
    |
    | Specify the provider that is used to store tokens in the blacklist
    |
    */

    'storage' => 'Tymon\JWTAuth\Providers\Storage\Illuminate',

config / app.php

'providers' => [
        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        //Remove both lines because for me worked without them
        //Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
        /*
         * Package Service Providers...
         */
        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
    ],

在存储/框架内部,您需要创建各种文件夹,分别是存储/框架/ 会话和存储/框架/ 视图

毕竟需要执行以下命令:

php artisan jwt:secret

[已编辑]

我现在看到此屏幕:

我希望那是你想要的

enter image description here