{"id":18834263,"url":"https://github.com/chubbyphp/chubbyphp-negotiation","last_synced_at":"2025-06-14T15:03:45.319Z","repository":{"id":56952689,"uuid":"102262001","full_name":"chubbyphp/chubbyphp-negotiation","owner":"chubbyphp","description":"A simple negotiation library.","archived":false,"fork":false,"pushed_at":"2025-03-12T14:09:19.000Z","size":138,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-25T04:07:06.421Z","etag":null,"topics":["accept","accept-language","content-negotiation","content-type-based-versioning","negotiation"],"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/chubbyphp.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,"zenodo":null}},"created_at":"2017-09-03T12:11:55.000Z","updated_at":"2025-03-12T14:09:22.000Z","dependencies_parsed_at":"2024-02-29T07:26:43.753Z","dependency_job_id":"3b76b818-b022-47ab-b286-f6a113d006c0","html_url":"https://github.com/chubbyphp/chubbyphp-negotiation","commit_stats":{"total_commits":81,"total_committers":5,"mean_commits":16.2,"dds":0.2098765432098766,"last_synced_commit":"bbea3c90dcd5f0d865d4c64c92ca867c7fb984e1"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/chubbyphp/chubbyphp-negotiation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chubbyphp%2Fchubbyphp-negotiation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chubbyphp%2Fchubbyphp-negotiation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chubbyphp%2Fchubbyphp-negotiation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chubbyphp%2Fchubbyphp-negotiation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chubbyphp","download_url":"https://codeload.github.com/chubbyphp/chubbyphp-negotiation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chubbyphp%2Fchubbyphp-negotiation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259835353,"owners_count":22918973,"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":["accept","accept-language","content-negotiation","content-type-based-versioning","negotiation"],"created_at":"2024-11-08T02:11:15.959Z","updated_at":"2025-06-14T15:03:45.296Z","avatar_url":"https://github.com/chubbyphp.png","language":"PHP","readme":"# chubbyphp-negotiation\n\n[![CI](https://github.com/chubbyphp/chubbyphp-negotiation/actions/workflows/ci.yml/badge.svg)](https://github.com/chubbyphp/chubbyphp-negotiation/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/chubbyphp/chubbyphp-negotiation/badge.svg?branch=master)](https://coveralls.io/github/chubbyphp/chubbyphp-negotiation?branch=master)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchubbyphp%2Fchubbyphp-negotiation%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/chubbyphp-negotiation/master)\n[![Latest Stable Version](https://poser.pugx.org/chubbyphp/chubbyphp-negotiation/v)](https://packagist.org/packages/chubbyphp/chubbyphp-negotiation)\n[![Total Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-negotiation/downloads)](https://packagist.org/packages/chubbyphp/chubbyphp-negotiation)\n[![Monthly Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-negotiation/d/monthly)](https://packagist.org/packages/chubbyphp/chubbyphp-negotiation)\n\n[![bugs](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![code_smells](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![coverage](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![duplicated_lines_density](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![ncloc](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=ncloc)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![sqale_rating](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![alert_status](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![reliability_rating](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![security_rating](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![sqale_index](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=sqale_index)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n[![vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=chubbyphp_chubbyphp-negotiation\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-negotiation)\n\n\n## Description\n\nA simple negotiation library.\n\n## Requirements\n\n * php: ^8.2\n * psr/http-message: ^1.1|^2.0\n\n## Suggest\n\n * chubbyphp/chubbyphp-container: ^2.2\n * chubbyphp/chubbyphp-http-exception: ^1.1\n * chubbyphp/chubbyphp-laminas-config-factory: ^1.3\n * pimple/pimple: ^3.5\n * psr/http-server-middleware: ^1.0.2\n\n## Installation\n\nThrough [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-negotiation][1].\n\n```sh\ncomposer require chubbyphp/chubbyphp-negotiation \"^2.2\"\n```\n\n## Usage\n\n### AcceptLanguageNegotiator\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\AcceptLanguageNegotiator;\n\n$request = ...;\n$request-\u003ewithHeader('Accept-Language', 'de,en-US;q=0.7,en;q=0.3');\n\n$negotiator = new AcceptLanguageNegotiator(['en', 'de']);\n$value = $negotiator-\u003enegotiate($request); // NegotiatedValue\n$value-\u003egetValue(); // de\n$value-\u003egetAttributes(); // ['q' =\u003e '1.0']\n```\n\n### AcceptLanguageMiddleware\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\Middleware\\AcceptLanguageMiddleware;\n\n$request = ...;\n$request-\u003ewithHeader('Accept-Language', 'de,en-US;q=0.7,en;q=0.3');\n\n$middleware = new AcceptLanguageMiddleware($acceptLanguageNegotiator);\n$response = $negotiator-\u003eprocess($request, $handler);\n```\n\n### AcceptNegotiator\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\AcceptNegotiator;\n\n$request = ...;\n$request-\u003ewithHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q =0.8');\n\n$negotiator = new AcceptNegotiator(['application/json', 'application/xml', 'application/x-yaml']);\n$value = $negotiator-\u003enegotiate($request); // NegotiatedValue\n$value-\u003egetValue(); // application/xml\n$value-\u003egetAttributes(); // ['q' =\u003e '0.9']\n```\n\n### AcceptMiddleware\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\Middleware\\AcceptMiddleware;\n\n$request = ...;\n$request-\u003ewithHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q =0.8');\n\n$middleware = new AcceptMiddleware($acceptNegotiator);\n$response = $negotiator-\u003eprocess($request, $handler);\n```\n\n### ContentTypeNegotiator\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\ContentTypeNegotiator;\n\n$request = ...;\n$request-\u003ewithHeader('Content-Type', 'application/xml; charset=UTF-8');\n\n$negotiator = new ContentTypeNegotiator(['application/json', 'application/xml', 'application/x-yaml']);\n$value = $negotiator-\u003enegotiate($request); // NegotiatedValue\n$value-\u003egetValue(); // application/xml\n$value-\u003egetAttributes(); // ['charset' =\u003e 'UTF-8']\n```\n\n### ContentTypeMiddleware\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\Middleware\\ContentTypeMiddleware;\n\n$request = ...;\n$request-\u003ewithHeader('Content-Type', 'application/xml; charset=UTF-8');\n\n$middleware = new ContentTypeMiddleware($contentTypeNegotiator);\n$response = $negotiator-\u003eprocess($request, $handler);\n```\n\n### NegotiationServiceFactory\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Container\\Container;\nuse Chubbyphp\\Negotiation\\ServiceFactory\\NegotiationServiceFactory;\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\n$container = new Container();\n$container-\u003efactories((new NegotiationServiceFactory())());\n\n$request = ...;\n\n$container-\u003eget('negotiator.acceptNegotiator')\n    -\u003enegotiate($request);\n\n$container-\u003eget('negotiator.acceptMiddleware')\n    -\u003eprocess($request, $handler);\n\n$container-\u003eget('negotiator.acceptLanguageNegotiator')\n    -\u003enegotiate($request);\n\n$container-\u003eget('negotiator.acceptLanguageMiddleware')\n    -\u003eprocess($request, $handler);\n\n$container-\u003eget('negotiator.contentTypeNegotiator')\n    -\u003enegotiate($request);\n\n$container-\u003eget('negotiator.contentTypeMiddleware')\n    -\u003eprocess($request, $handler);\n```\n\n### NegotiationServiceProvider\n\n```php\n\u003c?php\n\nuse Chubbyphp\\Negotiation\\ServiceProvider\\NegotiationServiceProvider;\nuse Pimple\\Container;\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\n$container = new Container();\n$container-\u003eregister(new NegotiationServiceProvider);\n\n$request = ...;\n\n$container['negotiator.acceptNegotiator']\n    -\u003enegotiate($request);\n\n$container['negotiator.acceptMiddleware']\n    -\u003eprocess($request, $handler);\n\n$container['negotiator.acceptLanguageNegotiator']\n    -\u003enegotiate($request);\n\n$container['negotiator.acceptLanguageMiddleware']\n    -\u003eprocess($request, $handler);\n\n$container['negotiator.contentTypeNegotiator']\n    -\u003enegotiate($request);\n\n$container['negotiator.contentTypeMiddleware']\n    -\u003eprocess($request, $handler);\n```\n\n### ServiceFactory\n\n * [AcceptLanguageMiddlewareFactory][2]\n * [AcceptLanguageNegotiatorFactory][3]\n * [AcceptMiddlewareFactory][4]\n * [AcceptNegotiatorFactory][5]\n * [ContentTypeMiddlewareFactory][6]\n * [ContentTypeNegotiatorFactory][7]\n\n## Copyright\n\n2025 Dominik Zogg\n\n[1]: https://packagist.org/packages/chubbyphp/chubbyphp-negotiation\n\n[2]: doc/ServiceFactory/AcceptLanguageMiddlewareFactory.md\n[3]: doc/ServiceFactory/AcceptLanguageNegotiatorFactory.md\n[4]: doc/ServiceFactory/AcceptMiddlewareFactory.md\n[5]: doc/ServiceFactory/AcceptNegotiatorFactory.md\n[6]: doc/ServiceFactory/ContentTypeMiddlewareFactory.md\n[7]: doc/ServiceFactory/ContentTypeNegotiatorFactory.md\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchubbyphp%2Fchubbyphp-negotiation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchubbyphp%2Fchubbyphp-negotiation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchubbyphp%2Fchubbyphp-negotiation/lists"}