gitmyhub

jwt

PHP ★ 7.5k updated 2d ago

A simple library to work with JSON Web Token and JSON Web Signature

A PHP library for creating, signing, and verifying JSON Web Tokens, the standard way to authenticate users across APIs without storing sessions, so any service can trust the same login.

PHPComposersetup: easycomplexity 2/5

This is a PHP library for creating, signing, and verifying JSON Web Tokens (JWTs) and JSON Web Signatures (JWS), following the RFC 7519 standard. JWTs are a widely used format for passing information between systems in a way that can be verified and trusted. The most common use case is user authentication: when someone logs in, a server issues a signed token, and the client includes that token in future requests to prove who they are, without the server needing to look up a session in a database each time.

A JWT works by bundling a set of claims (pieces of information, like a user ID or an expiry time) into a compact, URL-safe string, then signing that string with a cryptographic key. Anyone who receives the token can verify the signature to confirm it was issued by a trusted source and has not been altered in transit. This approach is popular for APIs and single-page applications where multiple services need to trust the same authentication state.

The library is installed via Composer, the standard PHP dependency manager. Once added to a project, it provides a structured API for building tokens with custom fields, applying signatures using supported algorithms, and validating incoming tokens.

The README for this project is minimal and refers readers to the full documentation hosted on ReadTheDocs for usage examples, algorithm options, and configuration details. It is available via Packagist, the main PHP package registry, and has accumulated nearly 7,500 GitHub stars, reflecting wide adoption across the PHP ecosystem over several years.

Where it fits