vkoori/laravel-jwt

There is no license information available for the latest version (0.1.0) of this package.

Integration of firebase/php-jwt library for laravel.

0.1.0 2025-07-18 07:33 UTC

This package is auto-updated.

Last update: 2025-07-18 07:36:44 UTC


README

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);