【问题标题】:how can i solve this error "Interface 'Tymon\JWTAuth\Contracts\JWTSubject' not found"我该如何解决这个错误“找不到接口'Tymon\JWTAuth\Contracts\JWTSubject'”
【发布时间】:2019-09-03 17:12:45
【问题描述】:

我使用本指南制作 jwt-auth https://medium.com/mesan-digital/tutorial-4-how-to-build-a-laravel-5-4-jwt-powered-mobile-app-api-4c59109d35f 当我尝试注册用户时,我发现了这个问题。 这是 composer.json 的要求

  "require": {
        "php": ">=7.1.3",
        "fideloper/proxy": "~4.0",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "tymon/jwt-auth": "1.0.0-rc.1"
    },

这里是 user.php "

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;

class User extends Authenticatable implements JWTSubject
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
    /**
     * Get the identifier that will be stored in the subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }
    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }
}"

【问题讨论】:

  • 如果你在命令行中运行composer show tymon/jwt-auth会得到什么?
  • 以防万一,运行composer dump-autoload
  • 什么也没发生:(
  • @IonMîndru 你解决了吗?

标签: php laravel jwt-auth


【解决方案1】:

我认为你应该看看这个thread,用这个依赖更新你的composer.json:

"tymon/jwt-auth": "^1.0.0-beta.3@dev"

然后运行composer update

【讨论】:

    【解决方案2】:
    name     : tymon/jwt-auth
    descrip. : JSON Web Token Authentication for Laravel and Lumen
    keywords : Authentication, JSON Web Token, auth, jwt, laravel
    versions : * 1.0.0-rc.2
    type     : library
    license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
    source   : [git] https://github.com/tymondesigns/jwt-auth.git d5220f6a84cbb8300f6f2f0f20aa908d072b4e4b
    dist     : [zip] https://api.github.com/repos/tymondesigns/jwt-auth/zipball/d5220f6a84cbb8300f6f2f0f20aa908d072b4e4b d5220f6a84cbb8300f6f2f0f20aa908d072b4e4b
    path     : /opt/lampp/htdocs/marusea/vendor/tymon/jwt-auth
    names    : tymon/jwt-auth
    
    autoload
    psr-4
    Tymon\JWTAuth\ => src/
    
    requires
    illuminate/auth 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    illuminate/contracts 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    illuminate/http 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    illuminate/support 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    lcobucci/jwt ^3.2
    namshi/jose ^7.0
    nesbot/carbon ^1.0
    php ^5.5.9 || ^7.0
    
    requires (dev)
    cartalyst/sentinel 2.0.*
    illuminate/console 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    illuminate/database 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    illuminate/routing 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
    mockery/mockery >=0.9.9
    phpunit/phpunit ~4.8 || ~6.0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-01
      • 2016-05-30
      • 1970-01-01
      • 2018-12-01
      • 1970-01-01
      • 2018-12-26
      • 2020-09-10
      • 2020-09-10
      相关资源
      最近更新 更多