PHPackages                             paulvl/jwt-guard - 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. paulvl/jwt-guard

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

paulvl/jwt-guard
================

JWT Guard for Laravel 5.\*

v1.2.2(8y ago)1518.0k↓17.9%6[4 issues](https://github.com/paulvl/jwt-guard/issues)1MITPHPPHP &gt;=5.5.9

Since Mar 2Pushed 8y ago3 watchersCompare

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

READMEChangelog (7)Dependencies (2)Versions (8)Used By (1)

JWT-Guard
---------

[](#jwt-guard)

JWT-Guard is a Laravel package that allow authentication and authorization as a guard driver using JWT tokens.

[![Latest Stable Version](https://camo.githubusercontent.com/155034cd7118bae42a3147fe87787787ccf5a2873dae905191b355555c311b53/68747470733a2f2f706f7365722e707567782e6f72672f7061756c766c2f6a77742d67756172642f762f737461626c65)](https://packagist.org/packages/paulvl/jwt-guard) [![Latest Unstable Version](https://camo.githubusercontent.com/777a37f86404597887a906dbdd4c852ed102ea64604f5db6a7f372e0aa3e659e/68747470733a2f2f706f7365722e707567782e6f72672f7061756c766c2f6a77742d67756172642f762f756e737461626c65)](https://packagist.org/packages/paulvl/jwt-guard) [![License](https://camo.githubusercontent.com/5b2f9441f903f8e92e45a57c82a9ae18fdda76eb595603a4a5d53bc44293b1f1/68747470733a2f2f706f7365722e707567782e6f72672f7061756c766c2f6a77742d67756172642f6c6963656e7365)](https://packagist.org/packages/paulvl/jwt-guard) [![Total Downloads](https://camo.githubusercontent.com/c9fb25f1ff18b17c146c5cd8b7c4b3d604e1e19213790b0ab813a7318371e8e5/68747470733a2f2f706f7365722e707567782e6f72672f7061756c766c2f6a77742d67756172642f646f776e6c6f616473)](https://packagist.org/packages/paulvl/jwt-guard)

**Quick Installation**
----------------------

[](#quick-installation)

Begin by installing this package through Composer.

You can run:

```
composer require paulvl/jwt-guard 1.*

```

Or edit your project's composer.json file to require paulvl/jwt-guard.

```
    "require": {
        "paulvl/jwt-guard": "1.*"
    }

```

Next, update Composer from the Terminal:

```
composer update

```

Once the package's installation completes, the final step is to add the service provider. Open `config/app.php`, and add a new item to the providers array:

```
Paulvl\JWTGuard\Auth\AuthServiceProvider::class,

```

Finally publish package's configuration file:

```
php artisan vendor:publish --provider="Paulvl\JWTGuard\Auth\AuthServiceProvider"

```

Then the file `config/jwt.php` will be created.

**JWT Guard**
-------------

[](#jwt-guard-1)

### **JWT driver setup!**

[](#jwt-driver-setup)

To start using JWT drive you need to create anew guard on `config/auth.php` file:

```
...
'guards' => [
        ...
        'jwt' => [
            'driver' => 'jwt',
            'provider' => 'users',
        ],
        ...
    ],
...

```

You can use any `Eloquent` provider that you want.

### **Using JWT Guard**

[](#using-jwt-guard)

\####**attempt**

```
    // Assuming you retrieve your credentials from request
    $credentials = [
        'email' => 'test@example.com',
        'password' => 'password'
    ];
    //this will return a token array
    return Auth::guard('jwt')->attempt($credentials);

```

#### **blacklistToken**

[](#blacklisttoken)

```
    //this will blacklist current jwt-token and referenced refresh token if exists
    return Auth::guard('jwt')->blacklistToken();

```

### **Using Valid JWT Middleware**

[](#using-valid-jwt-middleware)

if you need to validate Authentication using JWT token request just add `Paulvl\JWTGuard\Auth\Middleware\ValidJwt::class` to `routeMiddleware` on `Http/Kernel.php` file:

```
protected $routeMiddleware = [
    ...
    'valid-jwt' => \Paulvl\JWTGuard\Auth\Middleware\ValidJwt::class,
    ...
];

```

then if you need to verify a valid jwt-token

```
Route::middleware('valid-jwt:api_token')->get('/your-route', function (Request $request) {
    // any thing tha you need to protect
});

```

or if you need to verify a valid refresh-token

```
Route::middleware('valid-jwt:refresh_token')->get('/your-route', function (Request $request) {
    // your refresh action for example
});

```

### **Using Prebuild Controller**

[](#using-prebuild-controller)

JWT-Guard includes a prebuild controller that will handle Login, Token Refreshing and Blacklisting for you. Just add this to your routes file:

```
Route::post('/jwt/login', '\Paulvl\JWTGuard\Http\Controllers\Auth\LoginController@login')->name('jwt.login');

Route::post('/jwt/refresh', '\Paulvl\JWTGuard\Http\Controllers\Auth\LoginController@refresh')->name('jwt.refresh');

Route::post('/jwt/blacklist', '\Paulvl\JWTGuard\Http\Controllers\Auth\LoginController@blacklist')->name('jwt.blacklist');

```

**Contribute and share ;-)**
----------------------------

[](#contribute-and-share--)

If you like this little piece of code share it with you friends and feel free to contribute with any improvements.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~98 days

Recently: every ~30 days

Total

7

Last Release

3137d ago

Major Versions

v0.2.0 → v1.0.02017-06-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fdef0e996f65b82fd2c344429cd17177695635620eb34908c87dfbccd062fe0?d=identicon)[paulvl](/maintainers/paulvl)

---

Top Contributors

[![hu9osaez](https://avatars.githubusercontent.com/u/7918895?v=4)](https://github.com/hu9osaez "hu9osaez (1 commits)")

---

Tags

jwtjsonweblaraveltokenguard

### Embed Badge

![Health badge](/badges/paulvl-jwt-guard/health.svg)

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

###  Alternatives

[psecio/jwt

A JWT (JSON Web Token) Encoding &amp; Decoding library

109352.2k2](/packages/psecio-jwt)[unisharp/laravel-jwt

A jwt package for reisssuing token purpose based on jwt-auth package.

3610.5k1](/packages/unisharp-laravel-jwt)[benbjurstrom/cognito-jwt-guard

A laravel auth guard for JSON Web Tokens issued by Amazon AWS Cognito

1113.1k](/packages/benbjurstrom-cognito-jwt-guard)

PHPackages © 2026

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