首页 > 解决方案 > ReflectionException:文件中不存在类 Tymon\JWTAuth\Http\Middleware\Authenticate

问题描述

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

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

在此处输入图像描述

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

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

我的配置\app.php

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

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

标签: phplaraveljwt

解决方案


我修改了我放在后面的另一个文件:

您需要这样做,因为此错误已在开发分支中修复,但未在主分支中修复,因此请更改插件的某些内容。

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

app/Http/Kernel.php(替换你那里的那个)

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

配置/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',

配置/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,
    ],

在 storage/framework 内部,您需要创建各种文件夹,即 storage/framework/ session和 storage/framework/ views

毕竟需要做这个命令:

php artisan jwt:secret

[已编辑]

我现在看到了这个屏幕:

我希望那是你想要的

在此处输入图像描述


推荐阅读