PHPackages                             neoan3-apps/stateless - 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. neoan3-apps/stateless

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

neoan3-apps/stateless
=====================

stateless Json Webtoken (JWT) authentication / verification for PHP

v2.1.0(2y ago)0801[1 PRs](https://github.com/sroehrl/neoan3-stateless/pulls)6MITPHPPHP &gt;=8CI failing

Since Jan 22Pushed 3mo agoCompare

[ Source](https://github.com/sroehrl/neoan3-stateless)[ Packagist](https://packagist.org/packages/neoan3-apps/stateless)[ RSS](/packages/neoan3-apps-stateless/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (2)Versions (10)Used By (6)

[![Maintainability](https://camo.githubusercontent.com/6243fb82e8dbc4a469138f6258b6ab0116a76061967bf2200e6d2e06d9e43704/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35656637356232303830653739376239653965352f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/sroehrl/neoan3-stateless/maintainability)[![Test Coverage](https://camo.githubusercontent.com/84853e53ce4ee9a31c19ce20debf5cddd22fccbbe4661f2ebe0d312b27dcdedf/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35656637356232303830653739376239653965352f746573745f636f766572616765)](https://codeclimate.com/github/sroehrl/neoan3-stateless/test_coverage)[![Build Status](https://camo.githubusercontent.com/444224fd673a7219726f5e05e9028e01bd6915ef2ac5874dcb481d202b4e53a4/68747470733a2f2f7472617669732d63692e636f6d2f73726f6568726c2f6e656f616e332d73746174656c6573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/sroehrl/neoan3-stateless)

PHP stateless JWT authentication
================================

[](#php-stateless-jwt-authentication)

Easy implementation of JWT authentication &amp; handling in PHP.

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Methods](#methods)

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

[](#installation)

`composer require neoan3-apps/stateless`

Quick Start
-----------

[](#quick-start)

```
// static
Neoan3\Apps\Stateless::setSecret('My-super-secure-Key');

// or as object
// (method names are the same as static calls)
$stateless = new Neoan3\Apps\StatelessOOP('my-secure-key');

// create JWT
$jti = 'someId';
$scope = ['read', 'write'];
$payload = ['additional'=>'info']; // optional
$jwt = Neoan3\Apps\Stateless::assign($jti, $scope, $payload);

// validate JWT
try{
    $decrypted = Neoan3\Apps\Stateless::validate();
    $user = $decrypted['jti'];
} catch(Exception $e) {
    die('ups');
}
```

Methods
-------

[](#methods)

### setAuthorization($jwt)

[](#setauthorizationjwt)

If this method is not used, *Stateless* will read the Authorization from the $\_SERVER variable "HTTP\_AUTHORIZATION" and the following format "bearer *token*"

### setCustomException($class)

[](#setcustomexceptionclass)

Can be used to trigger a custom exception when encountering validation errors.

### setSecret($secret)

[](#setsecretsecret)

Key used for the HS256 algorithm (decryption/encryption/signing). Make sure a key is set prior to any other interactions.

### validate()

[](#validate)

Returns the decoded JWT or throws an Exception

### restrict($scope = \[\])

[](#restrictscope--)

Accepts a string or an array. Same as *validate*, but additionally checks if the right kind of scope is present.

### setExpiration($time | null)

[](#setexpirationtime--null)

Accepts strtotime-compatible expression or epoch-stamp.

### assign($jti, $scope, $payload = \[\])

[](#assignjti-scope-payload--)

Generates a JWT.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance54

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~517 days

Total

4

Last Release

749d ago

Major Versions

v1.0.1 → v2.0.02020-10-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/92d2361b646651e3452a62d07274076346c4096480098a6c43d6c27ee28d460d?d=identicon)[neoan](/maintainers/neoan)

---

Top Contributors

[![sroehrl](https://avatars.githubusercontent.com/u/28542911?v=4)](https://github.com/sroehrl "sroehrl (21 commits)")

---

Tags

hacktoberfestjwt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/neoan3-apps-stateless/health.svg)

```
[![Health](https://phpackages.com/badges/neoan3-apps-stateless/health.svg)](https://phpackages.com/packages/neoan3-apps-stateless)
```

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