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

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

malvik-lab/laravel-jwt
======================

JSON Web Token Authentication for Laravel

1.0.16(1y ago)057MITPHPPHP ^8.2

Since Oct 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/malvik-lab/laravel-jwt)[ Packagist](https://packagist.org/packages/malvik-lab/laravel-jwt)[ RSS](/packages/malvik-lab-laravel-jwt/feed)WikiDiscussions main Synced 1mo ago

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

Laravel JWT
===========

[](#laravel-jwt)

Laravel JWT is an open-source library for Laravel that adds JWT authentication to your project.
JWT is a token-based authentication method that is secure, lightweight, and easy to implement. The library is easy to use and can be configured in minutes. It provides a range of features for JWT authentication, including:

- Generating and validating JWT tokens
- Managing users and tokens
- Protecting routes and controllers

### Pre-installation (not mandatory)

[](#pre-installation-not-mandatory)

JWT uses a pair of public and private keys to sign and verify tokens. The public key is used to verify tokens on the client side, while the private key is used to sign tokens on the server side.

The library by default stores the public and private keys in a folder called **keys** in the root of your project. You can change the location of this folder by adding the following to your .env file:

```
JWT_KEYS_DIRECTORY_PATH=/path/to/jwt/keys/directory

```

### Library installation

[](#library-installation)

This command will install the library and all its dependencies.

```
composer require malvik-lab/laravel-jwt
```

### Publishing the configuration

[](#publishing-the-configuration)

This file contains the library configuration, such as the token signing method, token lifetime, and JWT key path.

```
php artisan vendor:publish --tag=jwt-config
```

### Migration publication

[](#migration-publication)

This file creates the jwt\_tokens table in your database. This table is used to store issued JWT tokens.

```
php artisan vendor:publish --tag=jwt-migration
```

### Running the migration

[](#running-the-migration)

This command will create the jwt\_tokens table in your database.

```
php artisan migrate
```

### JWT key generation

[](#jwt-key-generation)

this command will generate a public and private key pair, which will be used to sign and verify JWT tokens.

```
php artisan jwt:keys
```

### Add Guards

[](#add-guards)

Add new guards to auth configuration file.

```
