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

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

konstantinkotov/jwt
===================

A custom jwt token generator

1.0.0(2y ago)127MITPHPPHP ^8.0

Since Mar 21Pushed 2y ago1 watchersCompare

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

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

jwt
---

[](#jwt)

A custom jwt token generator

Installation via Composer:
--------------------------

[](#installation-via-composer)

```
composer require konstantinkotov/jwt
```

Settings:
---------

[](#settings)

### Step 1:

[](#step-1)

You must start a command below:

```
php artisan jwt:install
php artisan migrate
```

This will copy the necessary migration file to your database/migrations folder.

### Step 2:

[](#step-2)

Next you have to add *JWTSubjectTrait* to your User model:

```
use Konstantinkotov\jwt\Traits\JWTModelTrait;
```

If you need quickly access to token, you can add JWTControllerTrait to your controller files. Example:

```
use Konstantinkotov\jwt\Traits\JWTControllerTrait;
```

You'll have the access to the token inside your controller. You can obtain the token, using:

```
$token = $this->token();
```

The token will be searched in Authorization inside the headers params.

### Step 3:

[](#step-3)

If you need ready resource to your checks. You can use:

```
return (new \Konstantinkotov\jwt\Resources\AccessAllowedResource());

or

return (new \Konstantinkotov\jwt\Resources\AccessDeniedResource());
```

AccessAllowedResource will return, with status code 200:

```
{
  "token": "",
  "request_type": "bearer"
}
```

AccessDeniedResource will return, with status code 401:

```
{
  "error": "Unauthorized"
}
```

How to use:
-----------

[](#how-to-use)

```
$token = $user->generate();
```

This will create a token, save it to the api\_token column in users table.

Or you can use it using *JWT* class. For example:

```
\Konstantinkotov\jwt\JWT::token()->generate();
```

By default, the size is *100*.

### Result example:

[](#result-example)

```
2sxxQfkefRw4XuUX3d2UoPfIEnJIzPZZy.wBL8KdljmfPMPHp5jUk59sQ5xs3cMtPK5.lhmLchEZCpCUkckgukz0AEhkQzJunrT5o.v

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

788d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a4a78fee98513bfe93245971499c292837899cae6e37afdbd870aaccd302dbe?d=identicon)[Ko7ov](/maintainers/Ko7ov)

---

Top Contributors

[![Ko7ov-Konstantin](https://avatars.githubusercontent.com/u/100215876?v=4)](https://github.com/Ko7ov-Konstantin "Ko7ov-Konstantin (1 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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