{"id":22292020,"url":"https://github.com/aedart/athenaeum-etags","last_synced_at":"2025-07-28T23:32:56.257Z","repository":{"id":63908402,"uuid":"559525679","full_name":"aedart/athenaeum-etags","owner":"aedart","description":"[READ ONLY] Athenaeum ETags package - see https://github.com/aedart/athenaeum","archived":false,"fork":false,"pushed_at":"2024-11-28T08:52:02.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-28T09:34:03.596Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aedart.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-30T11:50:29.000Z","updated_at":"2024-11-28T08:52:06.000Z","dependencies_parsed_at":"2023-02-14T18:16:35.116Z","dependency_job_id":"81e92157-02e0-444b-8a31-8bb1738d1a3c","html_url":"https://github.com/aedart/athenaeum-etags","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"c89c4a2b06092c4706508ea90277cf702b335149"},"previous_names":[],"tags_count":67,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aedart%2Fathenaeum-etags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aedart%2Fathenaeum-etags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aedart%2Fathenaeum-etags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aedart%2Fathenaeum-etags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aedart","download_url":"https://codeload.github.com/aedart/athenaeum-etags/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227962323,"owners_count":17847936,"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":[],"created_at":"2024-12-03T17:19:19.206Z","updated_at":"2024-12-03T17:19:19.685Z","avatar_url":"https://github.com/aedart.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Athenaeum ETags\n\nThis package provides a \"profile\" based approach to generate [ETags](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag), and an evaluator to deal with [Http Conditional Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests), for your Laravel application.\n\n\n## ETags Examples\n\n### Generate\n\n```php\nuse Aedart\\ETags\\Facades\\Generator;\n\n// Generate an ETag for strong comparison, of content\n$etag = Generator::makeStrong($content);\n\necho (string) $etag; // \"4720b076892bb2fb65e75af902273c73a2967e4a\"\n```\n\nOr to generate ETags that are flagged as \"weak\" (_for weak comparison_)\n\n```php\n$etag = Generator::makeWeak($content);\n\necho (string) $etag; // W/\"0815\"\n```\n\n### Parsing\n\nTo parse ETags from Http headers, you can use the `parse()` method. It returns a collection of `ETag` instances.\n\n```php\n// E.g. If-None-Match: W/\"0815\", W/\"0816\", W/\"0817\"\n$collection = Generator::parse($request-\u003eheader('If-None-Match'));  \n\nforeach ($collection as $etag) {\n    echo (string) $etag;\n}\n```\n\n### Compare\n\nETags can also be matched against each other, in accordance with [RFC9110](https://httpwg.org/specs/rfc9110.html#rfc.section.8.8.3.2).\n\n#### Using Collection\n\n```php\n// Etags from Http Header\n$collection = Generator::parse($request-\u003eheader('If-Match')); // E.g. 'W/\"0815\"' \n\n// Other Etag for your resource\n$etag = Generator::makeWeak($content); // E.g. W/\"0815\"\n\n// Compare etags against resource's etag\necho $collection-\u003econtains($etag, true); // false - strong comparison\necho $collection-\u003econtains($etag);       // true - weak comparison\n```\n\n#### Using Etag instance\n\nYou can also compare individual `ETag` instances, using the `matches()` method.\n\n```php\n$etagA = Generator::parseSingle('W/\"0815\"');\n$etagB = Generator::parseSingle('W/\"0815\"');\n\necho $etagA-\u003ematches($etagB, true); // false - strong comparison\necho $etagA-\u003ematches($etagB);       // true - weak comparison\n```\n\n## Evaluate Http Preconditions Examples\n\nThe `Evaluator` component is able to process the incoming request against all the defined [RFC9110 preconditions](https://httpwg.org/specs/rfc9110.html#preconditions), in accordance with specified [evaluation precedence](https://httpwg.org/specs/rfc9110.html#precedence).\nDepending on the precondition requested, if it passes or fails, the request can either proceed or it will be aborted using customisable Http Exceptions.\nYour Laravel application should do the rest, whenever the request is aborted.\n\n```php\nuse Aedart\\ETags\\Preconditions\\Evaluator;\nuse Aedart\\ETags\\Preconditions\\Resources\\GenericResource;\n\n// Process If-Match, If-None-Match, If-Modified-Since... etc\n// Depending on condition's pass/fail, the request can be aborted via\n// an appropriate Http Exception, or proceed to your logic...\n$resource = Evaluator::make($request)\n    -\u003eevaluate(new GenericResource(\n        data: $model,\n        etag: $model-\u003egetStrongEtag(),\n        lastModifiedDate: $model-\u003eupdated_at\n    ));\n```\n\nTo summarise, the following preconditions are supported:\n\n* [If-Match](https://httpwg.org/specs/rfc9110.html#field.if-match)\n* [If-None-Match](https://httpwg.org/specs/rfc9110.html#field.if-none-match)\n* [If-Modified-Since](https://httpwg.org/specs/rfc9110.html#field.if-modified-since)\n* [If-Unmodified-Since](https://httpwg.org/specs/rfc9110.html#field.if-unmodified-since)\n* [If-Range](https://httpwg.org/specs/rfc9110.html#field.if-range)\n\nThe `Evaluator` also supports adding your own custom preconditions to be evaluated, should you need such.\n\n## Official Documentation\n\nPlease read the [official documentation](https://aedart.github.io/athenaeum/) for additional information.\n\nThe mono repository is located at [github.com/aedart/athenaeum](https://github.com/aedart/athenaeum)\n\n## Versioning\n\nThis package follows [Semantic Versioning 2.0.0](http://semver.org/)\n\n## License\n\n[BSD-3-Clause](http://spdx.org/licenses/BSD-3-Clause), Read the LICENSE file included in this package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faedart%2Fathenaeum-etags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faedart%2Fathenaeum-etags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faedart%2Fathenaeum-etags/lists"}