fuatogur/laravel-jwt

为Laravel提供的简单JWT身份验证

v1.0.0 2023-06-27 23:12 UTC

This package is auto-updated.

Last update: 2024-09-09 02:32:26 UTC


README

Laravel JWT身份验证

原因

虽然已有优秀的Laravel JWT包,但我认为它们过于复杂,因此创建了此包。

安装

  1. 首先使用composer安装此包
composer require fuatogur/laravel-jwt
  1. 将认证守护者设置为 jwt

用法

  1. 将getJWTData方法添加到您的User类中,以指定应包含在jwt令牌中的数据
class User extends Model
{
    public function getJWTData()
    {
        return [
            'id' => $this->id,
            'email' => $this->email
        ]
    }
}
  1. 使用 Auth::token() 获取用户的令牌