laravel-jwt maintained by vkoori
Description
Integration of firebase/php-jwt library for laravel.
Author
Last update
2025/07/18 18:11
(dev-master)
Downloads
503
Tags
Laravel JWT Integration with Firebase PHP JWT
This package provides a simple way to integrate JWT (JSON Web Tokens) for authentication in your Laravel application using the firebase/php-jwt library.
Installation
To install the package, run the following command:
composer require vkoori/laravel-jwt
Once the package is installed, you need to publish the provider using the following Artisan command:
php artisan vendor:publish --provider="Vkoori\LaravelJwt\JwtServiceProvider"
This will publish the config/jwt-config.php configuration file where you can manage the JWT settings.
Usage
Generating JWT Token
You can generate a JWT token by calling the service as follows:
\Vkoori\LaravelJwt\Services\Jwt::sign()
->setAudience($audience)
->setSubject($this->getAuthIdentifier())
->setScopes($scopes)
->setExpirationTime(Carbon::now()->addSeconds($ttl))
->encode();
Verifying JWT Token
To verify and decode the JWT token, you can use the following code:
Jwt::verify(token: $token);