PHPackages                             bedlate/laravel-jwt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bedlate/laravel-jwt

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

bedlate/laravel-jwt
===================

JSON Web Token Authentication for Laravel

0.0.2(6y ago)0591MITPHP

Since Mar 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bedlate/laravel-jwt)[ Packagist](https://packagist.org/packages/bedlate/laravel-jwt)[ Docs](https://github.com/bedlate/laravel-jwt)[ RSS](/packages/bedlate-laravel-jwt/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

laravel-jwt
===========

[](#laravel-jwt)

JSON Web Token Authentication for Laravel

Installation
------------

[](#installation)

1.Run the following command to pull in the latest version:

```
composer require bedlate/laravel-jwt

```

2.Add service provider ( Laravel 5.4 or below )

```
'providers' => [

    ...

    bedlate\JWT\JWTServiceProvider::class,
]

```

3.Publish the config

```
php artisan vendor:publish --provider="bedlate\JWT\JWTServiceProvider"

```

4.Generate secret key

```
php artisan jwt:keygen

```

Usage
-----

[](#usage)

1.Configure Auth guard

Inside the config/auth.php file you will need to add a guard.

```
'guards' => [
    ...

    'jwt' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ],
],

```

2.Add some basic authentication routes

So that you can add `auth:jwt` middleware to any routes you like.

```
Route::group([
    'middleware' => 'auth:jwt',
    'prefix' => 'auth'
], function ($router) {
    Route::post('refresh', 'AuthController@refresh');
    Route::post('user', 'AuthController@user');
});

Route::post('login', 'AuthController@login');

```

3.Create the AuthController

```
