Download the PHP package dev-toolbelt/jwt-token-manager without Composer

On this page you can find all versions of the php package dev-toolbelt/jwt-token-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package jwt-token-manager

JWT Token Manager

CI Coverage Latest Stable Version Total Downloads License PHP Version

A framework-agnostic PHP library for encoding, decoding, and validating JSON Web Tokens (JWT) with support for RSA, HMAC, ECDSA, and EdDSA algorithms.

Built with simplicity and security in mind, this package provides an easy way to manage JWT tokens without coupling your application to any specific framework.

Features

Requirements

Installation

Install via Composer:

Quick Start

1. Generate RSA Keys (if you don't have them)

Before using the library, you'll need an RSA key pair for signing and verifying tokens. If you already have keys, skip to step 2.

Linux / macOS

Open your terminal and run:

Windows

Option 1: Using Git Bash (recommended)

If you have Git installed, open Git Bash and use the same commands as Linux/macOS:

Option 2: Using WSL (Windows Subsystem for Linux)

Option 3: Using OpenSSL for Windows

  1. Download OpenSSL from slproweb.com/products/Win32OpenSSL.html
  2. Install and add to PATH
  3. Open Command Prompt and run the same commands

Production Keys (4096-bit)

For production environments, consider using stronger 4096-bit keys:

Security Note: Keep your private key secure and never commit it to version control. Add *.key to your .gitignore file.

2. Basic Usage

Configuration

Basic Configuration

Using Factory Methods

Supported Algorithms

Algorithm Type Description
HS256, HS384, HS512 HMAC Symmetric key algorithms
RS256, RS384, RS512 RSA Asymmetric RSA algorithms
ES256, ES384, ES512 ECDSA Elliptic Curve algorithms
PS256, PS384, PS512 RSA-PSS RSA with PSS padding
EdDSA EdDSA Edwards-curve Digital Signature

Why RS256 is the default? RS256 (RSA with SHA-256) is the most widely adopted algorithm in the industry, offering an excellent balance between security and performance. It uses asymmetric keys, allowing you to share the public key for verification while keeping the private key secure. This makes it ideal for distributed systems and microservices architectures.

Timezone Configuration

The library provides a type-safe Timezone enum with all PHP supported timezones. The default timezone is UTC.

Common timezone examples:

Note: JWT timestamps (iat, exp, nbf) are always Unix timestamps (seconds since Unix epoch), which are timezone-agnostic. The timezone configuration is used internally for consistent DateTimeImmutable operations and can be useful for logging, debugging, and future enhancements.

Usage

Generating Tokens

Token Claims

The generated token includes these standard claims:

Claim Description Customizable
iss Issuer (from config) No
sub Subject (user identifier) No
aud Audience (from config) Yes
iat Issued at timestamp No
exp Expiration timestamp No
nbf Not before timestamp Yes
jti Unique JWT ID (UUID v7) No
sid Session ID (UUID v7) No
typ Token type (default: "access") Yes

Note: Claims marked as Customizable: No are automatically generated and managed by the library to ensure token integrity and security. You cannot override these values.

Decoding Tokens

Below is a comprehensive example showing all possible exceptions that can be thrown during token decoding and validation:

Refresh Tokens

While refresh tokens are not mandatory, implementing them is highly recommended for a secure authentication flow. The concept is simple: access tokens should be short-lived (minutes to hours) to minimize the impact if compromised, while refresh tokens are long-lived (days to weeks) and used solely to obtain new access tokens. This approach reduces the attack window for stolen tokens while maintaining a smooth user experience without frequent re-authentication.

Best Practice: Store refresh tokens securely (e.g., in a database with the user association) and invalidate them when the user logs out or when suspicious activity is detected.

Overriding Optional Claims

Some claims can be overridden via custom claims for flexibility:

Note: Protected claims (iss, sub, iat, exp, jti, sid) cannot be overridden for security reasons.

Framework Integration Examples

Laravel

Symfony

Slim / PHP-DI

CodeIgniter 4

CakePHP 5

Yii2

Testing

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and follow the existing code style.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and follow PSR-12 coding standards.

Code Quality Requirements

Check Tool Requirement
Tests PHPUnit All tests must pass
Coverage PCOV Minimum 85% coverage
Code Style PHP CodeSniffer PSR-12 compliant
Static Analysis PHPStan Level 6, no errors

Pull Request Guidelines

Before submitting a PR, ensure:

  1. All tests pass: composer test
  2. Coverage is at least 85%: composer test:coverage
  3. Code style is correct: composer phpcs
  4. No static analysis errors: composer phpstan

Important: Pull requests with coverage below 85% will be automatically blocked by CI.

Coverage Report

License

MIT License. See LICENSE for details.


Made with ❤️ by Dev Toolbelt


All versions of jwt-token-manager with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
dev-toolbelt/enums Version ^1.0
firebase/php-jwt Version ^7.0
ramsey/uuid Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dev-toolbelt/jwt-token-manager contains the following files

Loading the files please wait ...