fuatogur/laravel-jwt

Simple JWT Authentication for Laravel

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

This package is auto-updated.

Last update: 2024-04-09 01:29:13 UTC


README

JWT Authentication for Laravel

Why

There are good laravel jwt packages but i saw them as complex and created this package.

Installation

  1. Firstly install the package via composer
composer require fuatogur/laravel-jwt
  1. Set your auth guard as jwt

Usage

  1. Add getJWTData method to your User class to specify which data should be included in jwt token
class User extends Model
{
    public function getJWTData()
    {
        return [
            'id' => $this->id,
            'email' => $this->email
        ]
    }
}
  1. Use Auth::token() to get the token for the user