{"id":19921116,"url":"https://github.com/corviz/jwt","last_synced_at":"2026-03-17T12:38:18.457Z","repository":{"id":56958284,"uuid":"464974813","full_name":"Corviz/jwt","owner":"Corviz","description":"Jwt library for PHP","archived":false,"fork":false,"pushed_at":"2022-03-22T17:27:07.000Z","size":83,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T10:05:23.747Z","etag":null,"topics":["authentication","jwt","php"],"latest_commit_sha":null,"homepage":"https://corviz.github.io/jwt/","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/Corviz.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-03-01T16:38:14.000Z","updated_at":"2022-05-23T02:59:29.000Z","dependencies_parsed_at":"2022-08-21T08:50:56.056Z","dependency_job_id":null,"html_url":"https://github.com/Corviz/jwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Corviz/jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corviz%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corviz%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corviz%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corviz%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Corviz","download_url":"https://codeload.github.com/Corviz/jwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corviz%2Fjwt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266699662,"owners_count":23970540,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["authentication","jwt","php"],"created_at":"2024-11-12T22:06:43.512Z","updated_at":"2026-03-17T12:38:18.424Z","avatar_url":"https://github.com/Corviz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT\n\n![JWT Logo](https://jwt.io/img/logo-asset.svg)\n\n## How to install\n\n```\ncomposer require corviz/jwt\n```\n\n## Provided signers\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eAlgorithm\u003c/th\u003e\n        \u003cth\u003eVersion\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eHS256\u003c/td\u003e\n        \u003ctd\u003e1.0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eHS384\u003c/td\u003e\n        \u003ctd\u003e1.0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eHS512\u003c/td\u003e\n        \u003ctd\u003e1.0\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n## Provided claim validators\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eClaim\u003c/th\u003e\n        \u003cth\u003eVersion\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eexp\u003c/td\u003e\n        \u003ctd\u003e1.0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003enbf\u003c/td\u003e\n        \u003ctd\u003e1.0\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n## Basic Usage\n\n### Generating token\n```php\n\u003c?php\n\nuse Corviz\\Jwt\\Token;\nuse Corviz\\Jwt\\SignerFactory;\n\n$token = Token::create()\n            -\u003ewith('exp', strtotime('+ 1 hour')) //Expires in one hour\n            -\u003ewithSigner(SignerFactory::build('HS256')) //HS256 signer is provided by default. This could be omitted\n            -\u003esign($mySecret)\n            -\u003etoString();\n```\n\n### Validating and reading values from a token\n```php\n\u003c?php\n\nuse Corviz\\Jwt\\Token;\n\n$token = Token::fromString('xxxx.yyyyy.zzzzz');\n\n$isValid = $token-\u003evalidate($mySecret);\n\nif ($isValid) {\n    $payload = $token-\u003egetPayload();\n    $headers = $token-\u003egetHeaders();\n}\n```\n\n### Validating your private claims\n\nFirst you have to create your validator\n\n```php\nuse \\Corviz\\Jwt\\Validator\\Validator;\n\nclass MyClaimValidator extends Validator {\n    /**\n     * @return string\n     */\n    public function validates() : string\n    {\n        return 'my-claim'; //this will validate value inside 'my-claim', when set\n    }\n    \n    /**\n     * @param mixed $value\n     * @return bool\n     */\n    public function validate(mixed $value) : bool\n    {\n        // this claim must contain value 'a', 'b' or 'c'\n        $valid = in_array($value, ['a', 'b', 'c']);\n        \n        return $valid;\n    }\n}\n```\n\nThen all you have to do is assign your validator before running *validate()* method\n```php\n\u003c?php\n\nuse Corviz\\Jwt\\Token;\n\n$token = Token::fromString('xxxx.yyyyy.zzzzz')\n            -\u003eassignValidator(new MyClaimValidator());\n\n$isValid = $token-\u003evalidate($mySecret);\n\nif ($isValid) {\n    $myClaim = $token-\u003egetPayload('my-claim');\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorviz%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorviz%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorviz%2Fjwt/lists"}