switon/jwt

JWT encoding, decoding, and key routing for Switon Framework

Maintainers

Package info

github.com/switon-php/jwt

Documentation

pkg:composer/switon/jwt

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-09 23:36 UTC

This package is auto-updated.

Last update: 2026-05-10 03:54:56 UTC


README

JWT encoding, decoding, and key routing for Switon Framework.

Installation

composer require switon/jwt

Requirements: PHP 8.3+

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Jwt\JwtInterface;

class AuthService
{
    #[Autowired] protected JwtInterface $jwt;

    public function issue(int $userId): string
    {
        return $this->jwt->encode(['user_id' => $userId], 3600);
    }

    public function authenticate(string $token): array
    {
        return $this->jwt->decode($token);
    }
}

Docs: https://docs.switon.dev/latest/jwt

License

MIT.