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

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

ociomercado/laravel-jwt
=======================

A simple Laravel package that implements a Provider, Middleware and Facade for JWT using lcobucci/jwt library to generate and check the tokens.

v0.4.2(9y ago)420MIT LicensePHP

Since Jan 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ociomercado/laravel-jwt)[ Packagist](https://packagist.org/packages/ociomercado/laravel-jwt)[ RSS](/packages/ociomercado-laravel-jwt/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (8)Dependencies (4)Versions (9)Used By (0)

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

[](#laravel-jwt)

A simple Laravel package that implements a `Provider`, `Middleware` and `Facade` for `JWT` using [lcobucci/jwt](https://github.com/lcobucci/jwt) library to generate and check the tokens.

Dependencies
------------

[](#dependencies)

This library requires:

- PHP 5.5+
- OpenSSL Extension

Installation
------------

[](#installation)

Using composer:

```
composer require ociomercado/laravel-jwt

```

Configuration
-------------

[](#configuration)

### Provider

[](#provider)

You need to update your `config/app.php` file and add the following code in the `providers` section:

```
  'providers' => [
    // Other providers

      OcioMercado\LaravelJWT\JWTServiceProvider::class,

    // Other providers
  ]
```

### Alias

[](#alias)

Also, you need to add the following in the `aliases` section:

```
  'aliases' => [
    // Other aliases

      'JWT' => OcioMercado\LaravelJWT\Facades\JWTFacade::class,

    // Other aliases
  ]
```

### Config file

[](#config-file)

Then you need to publish the configuration file so you customize the options:

```
php artisan vendor:publish

```

This will create the config file `jwt.php` in the `/config` folder. Don't forget to check it out and change the options as you need.

Using the library
-----------------

[](#using-the-library)

### Protecting routes

[](#protecting-routes)

Now you can use the `JWT` middleware to protect your routes:

```
  Route::get('/user', function (Request $request) {
    return 'Route secured!';
  })->middleware('JWT');
```

The `middleware` checks if the `request` has a `Authorization` header or the parameter `token` sent via `GET` or `POST`.

### The `JWT` class

[](#the-jwt-class)

```
  /**
   * Creates and signs a new JWT.
   *
   * It signs the token with the configured type of key in the jwt.php file.
   *
   * @param string $jti A unique identifier for the token.
   * @param mixed[] $customClaims Optional data to append to the token.
   *
   * @return Lcobucci\JWT\Token
   */
  public function createToken($jti = null, $customClaims = null)
```

```
  /**
   * Validates and verifies a JWT.
   *
   * It verfies the token with the configured type of key in the jwt.php file.
   *
   * @return Lcobucci\JWT\Token Returns the token.
   *
   * @throws TokenNotFoundException When the token is not found.
   * @throws InvalidTokenException When the token is not valid.
   * @throws InvalidTokenSignException When the token sign is not valid.
   */
  public function verifyToken($token)
```

```
  /**
   * Gets the JWT string from the request headers or from the GET parameter.
   *
   * @return string Returns the token string.
   *
   * @throws TokenNotFoundException When the token is not found.
   */
  public function getTokenString()
```

```
  /**
   * Parses the JWT string.
   *
   * @return Lcobucci\JWT\Token Returns the token.
   *
   * @throws TokenNotFoundException When the token is not found.
   * @throws InvalidTokenException When the token is not valid.
   */
  public function parseTokenString()
```

```
  /**
   * Checks if the JWT has expired.
   *
   * @throws TokenNotFoundException When the token is not found.
   * @throws InvalidTokenException When the token is not valid.
   * @throws TokenExpiredException When the token has expired.
   */
  public function tokenExpired()
```

```
  /**
   * Checks if the JWT can be refreshed.
   *
   * @return boolean Returns true is the token can be refreshed, otherwise it returns false.
   *
   * @throws TokenNotFoundException When the token is not found.
   * @throws InvalidTokenException When the token is not valid.
   */
  public function isRefreshableToken()
```

```
  /**
   * Gets the JWT object.
   *
   * @return Lcobucci\JWT\Token Returns the token.
   *
   * @throws TokenNotFoundException When the token is not found.
   * @throws InvalidTokenException When the token is not valid.
   */
  public function getToken()
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~6 days

Total

8

Last Release

3411d ago

### Community

Maintainers

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

---

Top Contributors

[![miniskulljob](https://avatars.githubusercontent.com/u/1895917?v=4)](https://github.com/miniskulljob "miniskulljob (14 commits)")

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/auth

The Illuminate Auth package.

9327.9M1.2k](/packages/illuminate-auth)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M120](/packages/laravel-mcp)[illuminate/routing

The Illuminate Routing package.

1239.0M2.8k](/packages/illuminate-routing)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)

PHPackages © 2026

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