little-apps/littlejwt

Secure Your Laravel Web App with Little JWT - The Key to Effortless Token Management!
26,291 3
Install
composer require little-apps/littlejwt
Latest Version:v3.0.0
PHP:^8.2
Laravel:12 · 13
Older releases:7 – 11
License:MIT
Last Updated:Aug 14, 2026
Links: GitHub  ·  Packagist
Maintainer: little-apps

Little JWT

Latest Version on Packagist GitHub Tests Action Status Format (PHP) codecov Total Downloads

Secure Your Laravel Web App with Little JWT - The Key to Effortless Token Management!

Show Your Support

Little Apps relies on people like you to keep our software running. If you would like to show your support for Little Registry Cleaner, then you can make a donation using PayPal, Payza or credit card (via Stripe). Please note that any amount helps (even just $1).

Requirements

  • PHP v8.2 or higher
  • Laravel 12.x or 13.x

Installation

Install the package via composer:

composer require little-apps/littlejwt

Publish the config file with:

php artisan vendor:publish --tag="littlejwt-config"

Generate a secret phrase for building and validating JWTs:

php artisan littlejwt:phrase

Information on generating different types of keys can be found in the documentation.

Upgrading

IMPORTANT: v3 removes support for Laravel 10 and 11. Ensure your app is on Laravel 12 or 13 before upgrading.

Create a backup of the config file:

cp config/littlejwt.php config/littlejwt.php.old

Upgrade the package via composer:

composer require little-apps/littlejwt:"^3.0"

Publish the new config file (overwriting the existing config file):

php artisan vendor:publish --tag="littlejwt-config" --existing

You will need to manually set the config file to match the old config file.

Usage

Building JWTs

use LittleApps\LittleJWT\Facades\LittleJWT;
use LittleApps\LittleJWT\Build\Builder;

$jwt = LittleJWT::create(function (Builder $builder) {
    $builder
        // Adds claim 'abc' with value 'def' to header claims.
        ->abc('def', true)
        // Adds claim 'ghi' with value 'klm' to payload claims.
        ->ghi('klm')
        // Adds claim 'nop' with value 'qrs' to payload claims.
        ->nop('qrs', false);
});

$token = (string) $jwt;
// $token = "ey...";

Validating JWTs

use LittleApps\LittleJWT\Facades\LittleJWT;
use LittleApps\LittleJWT\Validation\Validator;

$token = "ey...";

$passes = LittleJWT::validateToken($token, function (Validator $validator) {
    $validator
        // Checks the value of the 'abc' claim in the header === (strictly equals) 'def'
        ->equals('abc', 'def', true, true)
        // Checks the value of the 'ghi' claim in the payload == (equals) 'klm'
        ->equals('ghi', 'klm')
        // Checks the value of the 'nop' claim in the payload === (strictly equals) 'qrs'
        ->equals('nop', 'qrs', true, false);
});

if ($passes) {
    // JWT is valid.
} else {
    // JWT is invalid.
}

Further Documentation

Further documentation is located at docs.getlittlejwt.com.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

Libraries

Little JWT is built using the following libraries:

Contributors

Thank you to the following for their contributions:

License

The MIT License (MIT). Please see License File for more information.

Related Packages

tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

55,773,362 11,488
php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

13,275,763 843
dees040/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

81,200 0
tomfordrumm/jwt-auth

JSON Web Token Authentication for Laravel and Lumen (fork from tymon/jwt-auth)

62,823 2

Version History

Version Released PHP Laravel License
v3.0.0 ^8.2 ^13.0 || ^12.0 MIT
v2.3.1 ^8.1 ^12.0 || ^11.0 || ^10.0 MIT
v2.3.0 ^8.1 ^12.0 || ^11.0 || ^10.0 MIT
v1.5.1 ^7.4|^8.0|^8.1 ^7.0|^8.0|^9.0|^10.0 MIT
v1.5.0 ^7.4|^8.0|^8.1 ^7.0|^8.0|^9.0|^10.0 MIT
Pre-releases (5)
Version Released PHP Laravel License
v2.2.0-beta ^8.1||^8.2 ^10.0||^11.0 MIT
v2.1.1-beta ^8.1||^8.2 ^10.0||^11.0 MIT
v2.1.0-beta ^8.1||^8.2 ^10.0||^11.0 MIT
v2.0.1-beta ^7.4|^8.0|^8.1 ^7.0|^8.0|^9.0|^10.0 MIT
v2.0.0-beta ^7.4|^8.0|^8.1 ^7.0|^8.0|^9.0|^10.0 MIT