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

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

georgechem/jwt-auth
===================

Simple library to generate and validate json web token

v1.0.1(4y ago)015MITPHPPHP &gt;=8.0.0

Since Oct 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/georgechem/jwt-auth)[ Packagist](https://packagist.org/packages/georgechem/jwt-auth)[ RSS](/packages/georgechem-jwt-auth/feed)WikiDiscussions master Synced 5d ago

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

JWT token library
=================

[](#jwt-token-library)

---

Use composer to install:

```
composer require georgechem/jwt-auth
```

In root directory of your project create .env File like this

```
SERVER_SECRET='your server secret'
TOKEN_EXPIRE='5 minutes' // use time according to your needs
SERVER_DOMAIN = 'example.com' // server domain
HEADER_NAME='jwt-token' //name of header where jwt will be put
COOKIE_DOMAIN=localhost // for cookie verification
COOKIE_EXPIRE=60 cookie expire time in seconds
```

To generate token: in your entry point, generally index.php but can be any .php file

> To obtain token do POST request to entry point with following data:

```
$_POST['email'] and $_POST['password'] // data used internally to generate JWT
```

```
require __DIR__ . '/vendor/autoload.php';
$jwt = Jwt::getInstance();
// echo json response which can be consumed in javascript
$jwt->generate()->jsonResponse();
```

To verify token and authenticate/authorize user in entry point:

```
$jwt = Jwt::getInstance();
/**
 * Token verified successfully|fail
 * array[optional] may contain additional options for verifications
 * like: user role, server name etc...
 * @Return bool
 */
$jwt->verify(array());
```

Exemplary usage:
----------------

[](#exemplary-usage)

> Obtain token for new or already registered user:

```
use Georgechem\JwtAuth\Jwt\Jwt;

require __DIR__ . '/vendor/autoload.php';

// coming from traditional form or javascript
$_POST['email'] = 'user@email.com';
$_POST['password'] = 'user_password';

$jwt = Jwt::getInstance();
// json response may be consumed by javascript and token can be stored
// in local storage
$jwt->generate()->jsonResponse();
```

> Verify token for request

```
use Georgechem\JwtAuth\Jwt\Jwt;

require __DIR__ . '/vendor/autoload.php';

$jwt = Jwt::getInstance();
$_SERVER['jwt-token'] = 'that.token.should_be_from.header';
// if token is valid (not expired or malformed etc.)
if($jwt->verify()){
    //can use token data to do additional security checks manually
    var_dump($jwt->tokenData());
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

1663d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/52af715dcca3495a29ed630dbcce781f303e1e77a59cf35f91fc28a1881e7561?d=identicon)[georgechem](/maintainers/georgechem)

---

Top Contributors

[![georgechem](https://avatars.githubusercontent.com/u/54766527?v=4)](https://github.com/georgechem "georgechem (15 commits)")

### Embed Badge

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

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

###  Alternatives

[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)[rainlab/user-plugin

User plugin for October CMS

11954.3k13](/packages/rainlab-user-plugin)

PHPackages © 2026

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