PHPackages                             maksimovic/jose-php - 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. maksimovic/jose-php

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

maksimovic/jose-php
===================

JWT, JWS and JWS implementation in PHP

1.0.3(2mo ago)01.4kMITPHPPHP ^7.2 | ^8.0CI passing

Since Aug 22Pushed 2mo agoCompare

[ Source](https://github.com/maksimovic/jose-php)[ Packagist](https://packagist.org/packages/maksimovic/jose-php)[ Docs](https://github.com/maksimovic/jose-php)[ RSS](/packages/maksimovic-jose-php/feed)WikiDiscussions master Synced 1mo ago

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

JOSE
====

[](#jose)

> **Fork Notice:** This is a maintained fork of the abandoned [`gree/jose`](https://github.com/nov/jose-php) package. Updated with verified support for PHP 7.2 through 8.5.

PHP JOSE (JSON Object Signing and Encryption) Implementation

[![CI](https://github.com/maksimovic/jose-php/actions/workflows/ci.yml/badge.svg)](https://github.com/maksimovic/jose-php/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/6d6f5bf67fbadec17b5185fa4c3659645a5a018accb4fe2d3b90d0466a5fe12d/68747470733a2f2f636f6465636f762e696f2f6769746875622f6d616b73696d6f7669632f6a6f73652d7068702f67726170682f62616467652e7376673f746f6b656e3d4f4a5939424444494c4e)](https://codecov.io/github/maksimovic/jose-php)

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

[](#installation)

```
composer require maksimovic/jose-php
```

Requirements
------------

[](#requirements)

PHP 7.2 or later. [phpseclib](https://github.com/phpseclib/phpseclib) v2 is required (installed automatically via Composer).

Example
-------

[](#example)

### JWT

[](#jwt)

#### Encoding

[](#encoding)

```
$jwt = new JOSE_JWT(array(
    'foo' => 'bar'
));
$jwt->toString();
```

#### Decoding

[](#decoding)

```
$jwt_string = 'eyJ...';
$jwt = JOSE_JWT::decode($jwt_string);
```

### JWS

[](#jws)

#### Signing

[](#signing)

```
$private_key = "-----BEGIN RSA PRIVATE KEY-----\n....";
$jwt = new JOSE_JWT(array(
    'foo' => 'bar'
));
$jws = $jwt->sign($private_key, 'RS256');
```

NOTE: `$private_key` can be a `phpseclib\Crypt\RSA` instance.

#### Verification

[](#verification)

```
$public_key = "-----BEGIN RSA PUBLIC KEY-----\n....";
$jwt_string = 'eyJ...';
$jws = JOSE_JWT::decode($jwt_string);
$jws->verify($public_key, 'RS256');
```

NOTE: `$public_key` can be a `JOSE_JWK` or `phpseclib\Crypt\RSA` instance.

### JWE

[](#jwe)

#### Encryption

[](#encryption)

```
$jwe = new JOSE_JWE($plain_text);
$jwe->encrypt(file_get_contents('/path/to/public_key.pem'));
$jwe->toString();
```

#### Decryption

[](#decryption)

```
$jwt_string = 'eyJ...';
$jwe = JOSE_JWT::decode($jwt_string);
$jwe->decrypt($private_key);
```

### JWK

[](#jwk)

#### Encode

[](#encode)

##### RSA Public Key

[](#rsa-public-key)

```
$public_key = new phpseclib\Crypt\RSA();
$public_key->loadKey('-----BEGIN RSA PUBLIC KEY-----\n...');
JOSE_JWK::encode($public_key); # => JOSE_JWK instance
```

##### RSA Private Key

[](#rsa-private-key)

```
$private_key = new phpseclib\Crypt\RSA();
$private_key->setPassword($pass_phrase); # skip if not encrypted
$private_key->loadKey('-----BEGIN RSA PRIVATE KEY-----\n...');
JOSE_JWK::encode($private_key); # => JOSE_JWK instance
```

#### Decode

[](#decode)

##### RSA Public Key

[](#rsa-public-key-1)

```
$components = array(
    'kty' => 'RSA',
    'e' => 'AQAB',
    'n' => 'x9vNhcvSrxjsegZAAo4OEuo...'
);
JOSE_JWK::decode($components); # => phpseclib\Crypt\RSA instance
```

##### RSA Private Key

[](#rsa-private-key-1)

Not supported.

Development
-----------

[](#development)

```
git clone https://github.com/maksimovic/jose-php.git
cd jose-php
composer install
vendor/bin/phpunit test
```

License
-------

[](#license)

MIT. Copyright © 2013 Nov Matake &amp; GREE Inc. See LICENSE for details.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.2% 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 ~313 days

Total

4

Last Release

61d ago

### Community

Maintainers

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

---

Top Contributors

[![nov](https://avatars.githubusercontent.com/u/27299?v=4)](https://github.com/nov "nov (43 commits)")[![maksimovic](https://avatars.githubusercontent.com/u/1126226?v=4)](https://github.com/maksimovic "maksimovic (24 commits)")[![peter-svintsitskyi](https://avatars.githubusercontent.com/u/1718328?v=4)](https://github.com/peter-svintsitskyi "peter-svintsitskyi (8 commits)")[![vincib](https://avatars.githubusercontent.com/u/358692?v=4)](https://github.com/vincib "vincib (5 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (3 commits)")[![ledmonster](https://avatars.githubusercontent.com/u/975452?v=4)](https://github.com/ledmonster "ledmonster (1 commits)")

---

Tags

jwtJWSJWEJOSEJSON Web TokenJSON Web SignatureOpenID ConnectJSON Web EncryptionID Token

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maksimovic-jose-php/health.svg)

```
[![Health](https://phpackages.com/badges/maksimovic-jose-php/health.svg)](https://phpackages.com/packages/maksimovic-jose-php)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[sop/jwx

A PHP library for JSON web tokens (JWT) with signature (JWS) and encryption (JWE) support.

26257.5k1](/packages/sop-jwx)[web-token/jwt-framework

JSON Object Signing and Encryption library for PHP and Symfony Bundle.

94818.9M77](/packages/web-token-jwt-framework)[web-token/jwt-library

JWT library

2011.2M83](/packages/web-token-jwt-library)[web-token/jwt-bundle

JWT Bundle of the JWT Framework.

132.5M7](/packages/web-token-jwt-bundle)

PHPackages © 2026

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