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

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

legracieux53/jwt-laravel
========================

0.1.0(7y ago)016MITPHPPHP &gt;=5.3

Since May 25Pushed 7y agoCompare

[ Source](https://github.com/legraxieux53/jwt-laravel)[ Packagist](https://packagist.org/packages/legracieux53/jwt-laravel)[ RSS](/packages/legracieux53-jwt-laravel/feed)WikiDiscussions master Synced yesterday

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

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

[](#jwt-laravel)

Implementation of custom middleware that manage tokens for authentication in laravel framework.

Install
-------

[](#install)

`composer require legracieux53/jwt-laravel` or `composer require legracieux53/jwt-laravel:dev-master`

Usage
-----

[](#usage)

In your controller, import `AuthenticationManager` class and create authenticate function like that follow.

```
	...
	use Lnl\JWT\AuthenticationManager;

	...

	private function authenticate ($username, $password)
    {
        $manager = new AuthenticationManager();
        $manager->setTablePath("App\\Http\\Models"); // Set model namespace
        $manager->setTable("Person"); // set model table name
        $manager->setUsernameField("code_pers"); // set username field in table
        $manager->setPasswordField("password"); // set password field in table
        $manager->setUsername($username); //set username value
        $manager->setPassword($password); // set password value
        $status = $manager->login(); // perform login and get his state for checking
        if ($status == AuthenticationManager::LOGIN_SUCCESS) {
            return response()->json(["token" => $manager->getToken()], 200);
        } else {
            if ($status == AuthenticationManager::ERROR_USERNAME) {
                return response()->json(["message error" => "Vérifiez votre username ou mot de passe"], 403);
            }
            if ($status == AuthenticationManager::ERROR_PASSWORD) {
                return response()->json(["message error" => "Vérifiez votre mot de passe"], 403);
            }
        }
    }
```

Then use your `authenticate` function for login.

```
	...

	public function login (Request $request)
    {
        return $this->authenticate($request->code_pers, $request->password);
    }

	public function logout ($token)
    {
        $manager = new AuthenticationManager();
        $manager->setToken($token); // set token must be disabled
        $status = $manager->logout();
        if($status == AuthenticationManager::LOGOUT_SUCCESS) {
            return response()->json(["operation" => "success", "message" => "Déconnexion effectuée avec succès"], 200);
        }
        if($status == AuthenticationManager::LOGOUT_ERROR) {
            return response()->json(["operation" => "error", "message" => "Echec de l'oppération de déconnexion"], 403);
        }
    }
  	...
```

Now Create a middleware for checking authentication.

```
namespace App\Http\Middleware;

use Lnl\JWT\Token; //import The token class
use Closure;

class AuthenticationPerson
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $token = new Token();
        $token->clean(); // remove all expired tokens
        $token->setToken($request->token); // set token that your request has send.
        $token->setAgent("Person"); // set agent of token. It used for group tokens in authentication level. Use table name by default if AuthenticationManager::setAgent($agent) has not called in authentication function
        if ($token->tokenVerifyAgent() && $token->isToken() && $token->isValid()) {
            $token->relance(3600); // define new time for token
            return $next($request);
        } else {
            return response()->json(["Error Message" => "Invalid token provided"], 403);
        }
    }
}
```

You can now call `login` and `logout` functions in your routes like this:

```
Route::post('login/person', 'PersonController@login');

/**
 * Test de validité du token
 */
Route::middleware(['auth.ecole'])->group(function () {
    Route::get('logout/person/{token}', 'PersonController@logout');
    Route::get('test', function () {
        return response()->json(["message" => "connexion RAS"], 200);
    });
});
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2909d ago

### Community

Maintainers

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

---

Top Contributors

[![legraxieux53](https://avatars.githubusercontent.com/u/25818792?v=4)](https://github.com/legraxieux53 "legraxieux53 (11 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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