PHPackages                             framgia/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. framgia/laravel-jwt

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

framgia/laravel-jwt
===================

JSON Web Token (JWT) native guard for Laravel 5.2+

v0.1.0(9y ago)41432[4 issues](https://github.com/framgia/laravel-jwt/issues)MITPHP

Since May 19Pushed 9y ago8 watchersCompare

[ Source](https://github.com/framgia/laravel-jwt)[ Packagist](https://packagist.org/packages/framgia/laravel-jwt)[ RSS](/packages/framgia-laravel-jwt/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (10)Versions (2)Used By (0)

Native Laravel JWT Authentication Driver
========================================

[](#native-laravel-jwt-authentication-driver)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/37d71283101443981a9f1329aa5bb58a81aaad5d136364482e77cc395b13a0f7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6672616d6769612f6c61726176656c2d6a77742e737667)](https://scrutinizer-ci.com/g/framgia/laravel-jwt/?branch=master)[![Travis Build Status](https://camo.githubusercontent.com/6edef4f17f2af9a871ad4bc2fd117abb0d954a7d8e7c1d8fc295e855a135ce01/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6672616d6769612f6c61726176656c2d6a77742e737667)](https://travis-ci.org/framgia/laravel-jwt)[![Packagist Version](https://camo.githubusercontent.com/9cda8f7ba20790e3747c07e68ce1cca325db42635f41773ac8e00285c249ec42/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6672616d6769612f6c61726176656c2d6a77742e737667)](https://packagist.org/packages/framgia/laravel-jwt)

This package provides a native Laravel driver for JWT Authentication.

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

[](#installation)

To install this package you will need:

- Laravel 5.2 +
- PHP 5.5.9 + (Laravel dependency)

Install via **composer** - edit your `composer.json` to require the package.

```
"require": {
    "framgia/laravel-jwt": "0.1.*"
}
```

Then run `composer update` in your terminal to install it in.

*OR*

Run `composer require framgia/laravel-jwt` to automatically install latest version

After installation you need to add the service provider to your `app.php` config file.

```
'providers' => [
    // ...
    Framgia\Jwt\JwtServiceProvider::class,
    // ...
],
```

Configuration
-------------

[](#configuration)

Add the `jwt` driver configuration to your `auth.php` config file.

```
'guards' => [
    // ...
    'jwt' => [
        'driver' => 'jwt',
        'provider' => 'users', // May be replaced with preferred provider.
    ],
    // ...
],
```

`laravel-jwt` uses the application secret key for encrypting the tokens. You can use a separate key by defining the `JWT_KEY` environment variable in your server configuration or `.env` file.

In order to overwrite default settings publish the `jwt.php` config file to your project.

```
$ php artisan vendor:publish --provider="Framgia\Jwt\JwtServiceProvider"

```

Usage
-----

[](#usage)

To obtain the guard instance use the facade or service container.

```
Auth::guard('jwt');
app('auth')->guard('jwt');
```

The guard includes basic methods required by the `Guard` contract and following methods for authentication:

```
// Retrieve new authentication token by user credentials
$token = $guard->attempt($credentials);

// Blacklist current user token to discard authentication
$guard->logout();
```

In order to pass authentication, provide the returned token with `Authorization` header:

```
Authorization: Bearer TOKEN_HERE

```

By default token includes `jit`, `sub` and `exp` claims. If you need to provide custom claims, add `ProvidesCredentials` contract to your authenticatable instance.

```
// ...
use Framgia\Jwt\Contracts\ProvidesCredentials;
// ...

class User implements Authenticatable, ProvidesCredentials
{
    // ...

    /**
     * Get credentials for JWT.
     *
     * @return array
     */
    public function getCredentials()
    {
        return [
            'admin' => $this->isAdmin(),
            'role' => $this->role,
        ];
    }

    // ...
}
```

Contributing
------------

[](#contributing)

Use the GitHub repository [Issues](https://github.com/framgia/laravel-jwt/issues) to report bugs or [Pull Requests](https://github.com/framgia/laravel-jwt/pulls) to provide bug fixes and feature updates.

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2016 Framgia Vietnam Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

See Also
--------

[](#see-also)

- [JWT Auth package](https://github.com/tymondesigns/jwt-auth) by Sean Tymon

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3645d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/63663c27f1d7e87cbd4472c0d3e0920bdb1cc85e8a1ad7f8d875171ce6e46ca9?d=identicon)[rkgrep](/maintainers/rkgrep)

![](https://www.gravatar.com/avatar/d02a398b3a64f7ce04edd952919f4c888b65bc2761c0f804d1188015e2fdcfed?d=identicon)[tungpro](/maintainers/tungpro)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/framgia-laravel-jwt/health.svg)

```
[![Health](https://phpackages.com/badges/framgia-laravel-jwt/health.svg)](https://phpackages.com/packages/framgia-laravel-jwt)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2011.0k](/packages/alajusticia-laravel-logins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
