{"id":15030335,"url":"https://github.com/anshu-krishna/php-jwt","last_synced_at":"2025-12-26T12:40:36.632Z","repository":{"id":56948670,"uuid":"463430120","full_name":"anshu-krishna/PHP-JWT","owner":"anshu-krishna","description":"JSON Web Token library for PHP","archived":false,"fork":false,"pushed_at":"2022-02-25T07:58:42.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T22:50:56.749Z","etag":null,"topics":["jwt","jwt-tokens","php","php81"],"latest_commit_sha":null,"homepage":"","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/anshu-krishna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-25T06:56:54.000Z","updated_at":"2022-04-12T06:01:11.000Z","dependencies_parsed_at":"2022-08-21T07:20:54.554Z","dependency_job_id":null,"html_url":"https://github.com/anshu-krishna/PHP-JWT","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FPHP-JWT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FPHP-JWT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FPHP-JWT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FPHP-JWT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anshu-krishna","download_url":"https://codeload.github.com/anshu-krishna/PHP-JWT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243349569,"owners_count":20276622,"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","jwt-tokens","php","php81"],"created_at":"2024-09-24T20:13:08.239Z","updated_at":"2025-12-26T12:40:36.596Z","avatar_url":"https://github.com/anshu-krishna.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Web Token library for PHP\r\n## Installation:\r\n```\r\ncomposer require anshu-krishna/php-jwt\r\n```\r\n- Generate JWT\r\n- Verify JWT\r\n- Supported Std Claims:\r\n\t- `iss`\r\n\t- `sub`\r\n\t- `aud`\r\n\t- `exp`\r\n\t- `nbf`\r\n\t- `iat`\r\n\t- `jti`\r\n\t- `kid`\r\n- Supported Signature Algorithms:\r\n\t- `HS256`\r\n\t- `HS384`\r\n\t- `HS512`\r\n\t- `RS256`\r\n\t- `RS384`\r\n\t- `RS512`\r\n\r\n## Example (Basic):\r\nRead and verify JWT:\r\n```php\r\nuse Krishna\\JWT\\JWT;\r\n\r\n$secret_key = 'your-secret';\r\n\r\n$jwt = new JWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b2tlbi50ZXN0LmNvbSIsImF1ZCI6ImFwcC50ZXN0LmNvbSIsImlhdCI6MTY0Mzg5MTc1OCwibmJmIjoxNjQzODkxNzU4LCJleHAiOjE2NzI1MzQ4MDAsIm5hbWUiOiJBbnNodSBLcmlzaG5hIiwiY2l0eSI6IkJhbmdhbG9yZSIsImp0aSI6IjZmZGZhY2JkLWU1N2MtNDI1Yy1hNDBmLWM3NjQ5YjBkNDg0MSJ9.U7o6m77GP3oX_A_DgjgkS6U9rSLspPkOL_1dQLkr6QM');\r\n\r\nvar_dump(['JWT' =\u003e $jwt]);\r\n\r\necho \"\u003chr /\u003e\";\r\nvar_dump(['Verify' =\u003e $jwt-\u003everify($secret_key)]);\r\n\r\n```\r\nOutput:\r\n```\r\n...file_path...\\index.php:50:\r\narray (size=1)\r\n  'JWT' =\u003e \r\n    object(Krishna\\JWT\\JWT)[3]\r\n      public 'enc' =\u003e string 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b2tlbi50ZXN0LmNvbSIsImF1ZCI6ImFwcC50ZXN0LmNvbSIsImlhdCI6MTY0Mzg5MTc1OCwibmJmIjoxNjQzODkxNzU4LCJleHAiOjE2NzI1MzQ4MDAsIm5hbWUiOiJBbnNodSBLcmlzaG5hIiwiY2l0eSI6IkJhbmdhbG9yZSIsImp0aSI6IjZmZGZhY2JkLWU1N2MtNDI1Yy1hNDBmLWM3NjQ5YjBkNDg0MSJ9' (length=281)\r\n      public 'sig' =\u003e string 'S�:���?z\u0017\u000fÂ8$K�=�\"�\u000e/]@�+�\u0003' (length=32)\r\n      public 'head' =\u003e \r\n        array (size=2)\r\n          'alg' =\u003e string 'HS256' (length=5)\r\n          'typ' =\u003e string 'JWT' (length=3)\r\n      public 'body' =\u003e \r\n        array (size=8)\r\n          'iss' =\u003e string 'token.test.com' (length=14)\r\n          'aud' =\u003e string 'app.test.com' (length=12)\r\n          'exp' =\u003e int 1672534800\r\n          'nbf' =\u003e int 1643891758\r\n          'iat' =\u003e int 1643891758\r\n          'jti' =\u003e string '6fdfacbd-e57c-425c-a40f-c7649b0d4841' (length=36)\r\n          'name' =\u003e string 'Anshu Krishna' (length=13)\r\n          'city' =\u003e string 'Bangalore' (length=9)\r\n\r\n...file_path...\\index.php:53:\r\narray (size=1)\r\n  'Verify' =\u003e \r\n    object(Krishna\\DataValidator\\Returner)[26]\r\n      public readonly mixed 'value' =\u003e boolean true\r\n      public readonly mixed 'error' =\u003e null\r\n      public readonly bool 'valid' =\u003e boolean true\r\n\r\n```\r\n\r\nCreate JWT:\r\n```php\r\nuse Krishna\\JWT\\Algo;\r\nuse Krishna\\JWT\\JWT;\r\n\r\n$secret_key = 'your-secret';\r\n\r\n$jwt = new JWT;\r\n\r\n$jwt['name'] = 'AK';\r\n$jwt['country'] = 'India';\r\n\r\n$jwt-\u003esign($secret_key, Algo::HS512);\r\n\r\necho \"Token: \", $jwt, \"\u003cbr\u003e\u003cbr\u003e\";\r\n\r\nvar_dump($jwt);\r\n```\r\nOutput:\r\n```\r\nToken: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiQUsiLCJjb3VudHJ5IjoiSW5kaWEiLCJpYXQiOjE2NDU3NzU3MDUsIm5iZiI6MTY0NTc3NTcwNSwiaXNzIjoidGVzdC5zZXJ2ZXIiLCJleHAiOjE2NDU3NzYzMDUsImp0aSI6IjI5YWUyZTJmLTM0NGMtNDcyMy05OWMwLTMzZWEyNzRmMDMxMSJ9.pBqcBMMjeCtpzW1EarehRwsk-hBbZmZr0z1uwPii0oITsCiZ8orPIEjGgHIPC9jesd3AqoxOuCXUdA-MXhy05w\r\n\r\n...file_path...\\index.php:57:\r\nobject(Krishna\\JWT\\JWT)[3]\r\n  public 'enc' =\u003e string 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiQUsiLCJjb3VudHJ5IjoiSW5kaWEiLCJpYXQiOjE2NDU3NzU3MDUsIm5iZiI6MTY0NTc3NTcwNSwiaXNzIjoidGVzdC5zZXJ2ZXIiLCJleHAiOjE2NDU3NzYzMDUsImp0aSI6IjI5YWUyZTJmLTM0NGMtNDcyMy05OWMwLTMzZWEyNzRmMDMxMSJ9' (length=233)\r\n  public 'sig' =\u003e string '�\u001a�\u0004�#x+i�mDj��G\u000b$\u0010[ffk�=n��҂\u0013�(��� Hƀr\u000f\u000b�ޱ����N�%�t\u000f�^\u001c��' (length=64)\r\n  public 'head' =\u003e \r\n    array (size=2)\r\n      'alg' =\u003e string 'HS512' (length=5)\r\n      'typ' =\u003e string 'JWT' (length=3)\r\n  public 'body' =\u003e \r\n    array (size=7)\r\n      'name' =\u003e string 'AK' (length=2)\r\n      'country' =\u003e string 'India' (length=5)\r\n      'iat' =\u003e int 1645775705\r\n      'nbf' =\u003e int 1645775705\r\n      'iss' =\u003e string 'test.server' (length=11)\r\n      'exp' =\u003e int 1645776305\r\n      'jti' =\u003e string '29ae2e2f-344c-4723-99c0-33ea274f0311' (length=36)\r\n\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanshu-krishna%2Fphp-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanshu-krishna%2Fphp-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanshu-krishna%2Fphp-jwt/lists"}