Download the PHP package daycry/jwt without Composer

On this page you can find all versions of the php package daycry/jwt. 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

JWT for CodeIgniter 4

A JWT (JSON Web Token) library for CodeIgniter 4, built on top of lcobucci/jwt ^5. Supports HMAC, RSA and ECDSA, an immutable faΓ§ade, and key rotation.

πŸ“– Full documentation: https://daycry.github.io/jwt/ β€” this README is a quick overview; the site has the complete, searchable reference.

Package

Latest Stable Version Total Downloads Monthly Downloads PHP Version Require License

Quality

PHP Tests PHPStan Psalm Rector Code Style CodeQL Docs Coverage Status

Community

GitHub stars Donate


Requirements

Upgrading from v2.x? Read the v2 β†’ v3 migration guide.


Installation

Publish the configuration file

Generate a signing key

The key is written automatically to .env as jwt.signer. Use --show to print it without touching the file.

⚠️ Never commit .env to version control.


Quick Start

The library throws JWTConfigurationException if jwt.signer, jwt.issuer, jwt.audience, or jwt.identifier is missing β€” both null and an empty string "" are rejected. Defaults are intentionally null to fail loudly.


Configuration

After publishing, edit app/Config/JWT.php. All properties are inherited from Daycry\JWT\Config\JWT and overridable via .env.

HMAC (default)

RSA / ECDSA

In app/Config/JWT.php set the signer class:

See docs/configuration.md for the full reference.


Usage

Compact array payload (default)

Split mode β€” claims at the top level

Custom payload claim name

Short-lived tokens (withExpiresAt)

Override the configured expiresAt modifier for a single instance, without mutating the shared config β€” useful for short-lived access tokens. Like every with*() method it returns a new instance. Passing an empty string throws InvalidArgumentException.

Clock skew tolerance (LooseValidAt)

withLeeway() accepts null to reset to "no leeway"; a negative value throws InvalidArgumentException.

Per-instance customisers (3.2.0)

Every customiser returns a new instance, leaving the shared config untouched. Override claims, audiences, headers and extra claims per call:

Key rotation with kid (3.2.0)

Tag issued tokens with a kid header and verify against a per-kid key map, so you can roll keys without invalidating tokens still in flight:

On decode, the token's kid selects the matching key from $verifyingKeys (falling back to $verifyingKey / $signer). The configured signer/algorithm is always used, so a token's kid can never downgrade the verifier.


Error Handling

For a non-throwing flow:

Fail-closed configuration guards

The library refuses unsafe configurations up front instead of silently producing weak tokens. JWTConfigurationException is thrown when:

An invalid jwt.canOnlyBeUsedAfter or jwt.expiresAt modifier (anything DateTimeImmutable::modify() rejects) throws InvalidArgumentException consistently across PHP versions.


Utility Methods

Method Returns Description
decode(string $token) Plain Validates and returns the parsed token. Throws on failure.
tryDecode(string $token) ?Plain Like decode() but returns null on a token failure. A JWTConfigurationException (misconfiguration) still propagates.
getPayload(string $token) mixed Validates + returns the original payload (auto-decoded for compact mode).
getClaims(string $token) array Validated array of all claims (the safe counterpart of extractClaimsUnsafe()).
getClaim(string $token, string $name) mixed Validated single claim value (null when absent).
isValid(string $token) bool True iff tryDecode() succeeds.
isExpired(string $token) bool True for malformed/expired tokens. Parses without verifying the signature β€” never gate access on it.
getTimeToExpiry(string $token) ?int Seconds until exp, or null. Does not verify the signature.
extractClaimsUnsafe(string $token) ?array Claims without validation. Logs a warning unless Config::$allowUnsafeExtraction = true.

CLI Commands

On Windows, jwt:keypair warns that chmod() cannot enforce file permissions β€” restrict the private key with NTFS ACLs (e.g. icacls) instead. It also warns when --passphrase is passed on the command line, because that value can leak via the process list and shell history; prefer a secrets manager or interactive entry.


Security Best Practices

  1. Use a strong key β€” php spark jwt:key enforces a 32-byte (256-bit) minimum, the floor for HS256.
  2. Set short expiry times for API access tokens (withExpiresAt('+15 minutes')).
  3. Enable all validation constraints in production (keep 'SignedWith' in jwt.validateClaims).
  4. Never commit .env or any file containing jwt.signer / private keys.
  5. Rotate keys without downtime using the kid header and jwt.verifyingKeys map (see Key rotation) β€” keep the old key in the map until its tokens have expired, then drop it. If a key is leaked, remove it from the map immediately to revoke its tokens.

Testing


Documentation

πŸ“– The full, searchable documentation is published at https://daycry.github.io/jwt/ (built with MkDocs Material from the docs/ folder).

Document Description
Getting Started Installation and first token in minutes
Configuration Every property, its type, default, and .env key
Usage Complete API reference with examples
Advanced Utility methods, key rotation, middleware, multi-tenant patterns
CLI Commands jwt:key, jwt:keypair, jwt:publish reference
Threat Model Security model and guarantees
Testing Test suite structure and writing new tests
Migration v2 β†’ v3 Upgrade guide

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push and open a Pull Request

License

MIT β€” see LICENSE.


Support


All versions of jwt with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
lcobucci/clock Version ^3.0
lcobucci/jwt Version ^5.5
psr/clock Version ^1.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 daycry/jwt contains the following files

Loading the files please wait ...