{"id":23953772,"url":"https://github.com/musa11971/php-jwt-decoder","last_synced_at":"2025-04-13T01:40:01.279Z","repository":{"id":53152701,"uuid":"243589796","full_name":"musa11971/php-jwt-decoder","owner":"musa11971","description":"🔑 A lightweight and flexible library to decode JWTs.","archived":false,"fork":false,"pushed_at":"2021-04-04T11:15:51.000Z","size":62,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T01:39:49.209Z","etag":null,"topics":["jwt","php","php-library"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/musa11971.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-27T18:37:46.000Z","updated_at":"2024-08-12T19:58:11.000Z","dependencies_parsed_at":"2022-09-07T02:52:00.688Z","dependency_job_id":null,"html_url":"https://github.com/musa11971/php-jwt-decoder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musa11971%2Fphp-jwt-decoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musa11971%2Fphp-jwt-decoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musa11971%2Fphp-jwt-decoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musa11971%2Fphp-jwt-decoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/musa11971","download_url":"https://codeload.github.com/musa11971/php-jwt-decoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654027,"owners_count":21140236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jwt","php","php-library"],"created_at":"2025-01-06T14:37:37.244Z","updated_at":"2025-04-13T01:40:01.256Z","avatar_url":"https://github.com/musa11971.png","language":"PHP","funding_links":["https://www.paypal.me/musa11971)!"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\".github/logo.png\" width=\"400\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://packagist.org/packages/musa11971/php-jwt-decoder\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/musa11971/php-jwt-decoder.svg?style=flat-square\" alt=\"Latest version on packagist\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/musa11971/php-jwt-decoder/actions?query=workflow%3Arun-tests+branch%3Amaster\"\u003e\u003cimg src=\"https://img.shields.io/github/workflow/status/musa11971/php-jwt-decoder/run-tests?label=tests\" alt=\"GitHub Tests Action Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/musa11971/php-jwt-decoder\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/musa11971/php-jwt-decoder.svg?style=flat-square\" alt=\"Total downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003csup\u003e\u003cem\u003elightweight and easy to use. what more could you want\u003c/em\u003e\u003c/sup\u003e\n\u003c/p\u003e\n\n# Easily decode JWT\n\nThis lightweight PHP library helps you decode and verify JSON Web Tokens easily.\n\n```php\n$payload = JWTDecoder::token($jwt)\n                -\u003ewithKey($publicKey)\n                -\u003edecode();\n```\n\n## Installation\n\nYou can install the library via composer:\n\n```bash\ncomposer require musa11971/php-jwt-decoder\n```\n\n## Usage\n\n### Basic decoding\nPass on your JWT and (public) key (e.g. PEM) as strings.\n```php\n$payload = JWTDecoder::token($jwt)\n                -\u003ewithKey($key)\n                -\u003edecode();\n```\n\n### Decoding with multiple keys\nYou may have multiple potential keys, one of which is the correct one for the JWT. This library allows you to simply pass on all the keys, and it will try every key until the signature is verified.  \nDo note that if none of the keys are correct, you will be met with an exception.\n```php\n$keys = [...]; // Array of keys\n\n$payload = JWTDecoder::token($jwt)\n                -\u003ewithKeys($keys)\n                -\u003edecode();\n```\n\n### Ignoring the token expiry time\nBy default, the library will check the token's expiry time ([exp](https://tools.ietf.org/html/rfc7519#section-4.1.4)) if it is present. However, if (for whatever reason) you wish to ignore the expiry time, you can use the following option. \n```php\n$payload = JWTDecoder::token($jwt)\n                -\u003ewithKey($key)\n                -\u003eignoreExpiry()\n                -\u003edecode();\n```\n\n### Ignoring the token 'not valid before' time\nSimilarly to the `ignoreExpiry` option, you can also ignore the 'not valid before' time of the token ([nbf](https://tools.ietf.org/html/rfc7519#section-4.1.5)).\n```php\n$payload = JWTDecoder::token($jwt)\n                -\u003ewithKey($key)\n                -\u003eignoreNotValidBefore()\n                -\u003edecode();\n```\n\n### Working with the payload\nThe decoder always returns a `JWTPayload` instance. Use this object to access the data in the payload.  \n  \n**Check if payload has a value**\n```php\n$payload-\u003ehas('username'); // true\n$payload-\u003ehas('date_of_birth'); // false\n```\n\n**Get a value from the payload**\n```php\n$payload-\u003eget('username'); // 'John'\n```\n\n**Convert a payload to an array**\n```php\n$payload-\u003etoArray();\n\n/*\n * [\n *   'username'     =\u003e 'John',\n *   'email'        =\u003e 'john@example.com',\n *   'sub'          =\u003e '1234567890',\n *   'iat'          =\u003e 1516239022,\n *   'exp'          =\u003e 1516243210\n * ]\n */\n```\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email mussesemou99@gmail.com instead of using the issue tracker.\n\n## Credits\n\nCredits go to [musa11971](https://github.com/musa11971) for creating and maintaining the library.  \n\nSpecial thanks  \n- .. to [all contributors](../../contributors) for contributing to the project.\n\n## Support me\n\nI am a full-time software engineering student and work on this library in my free time. If you find the library useful, please consider making a [donation](https://www.paypal.me/musa11971)! Every little bit helps. 💜\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusa11971%2Fphp-jwt-decoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmusa11971%2Fphp-jwt-decoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusa11971%2Fphp-jwt-decoder/lists"}