laravel-shine / jwt
Simple JSON Web Token for PHP
Installs: 340
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/laravel-shine/jwt
Requires
- php: ^7.0 || ^8.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-12-11 11:35:42 UTC
README
Simple JSON Web Token for PHP
Requirements
- PHP > 7.0
- OpenSSL
Capabilities
| Function | Algorithm |
|---|---|
| ✅ Sign | ✅ HS256 |
| ✅ Verify | ✅ HS384 |
❎ iss check |
✅ HS512 |
❎ sub check |
✅ RS256 |
❎ aud check |
✅ RS384 |
❎ exp check |
✅ RS512 |
❎ nbf check |
|
❎ iat check |
|
❎ jti check |
Basic Usage
encode(array payload, string $key, string $algorithm)
try { $token = JWT::encode(['sub' => '1234567890', 'name' => 'John Smith'], $key256bit, 'HS256'); } catch (\Exception $e) { // encode error }
decode(string $token, string $key)
try { $payload = JWT::decode($token, $key256bit); // $payload->sub == '1234567890' } catch (\Exception $e) { // $e->getCode() }
Exceptions
decode()
| Code | Reason |
|---|---|
| 1 | Invalid token format |
| 2 | Invalid header encoding |
| 3 | Invalid token header |
| 4 | Algorithm not supported |
| 5 | Invalid payload encoding |
| 6 | Invalid signature |