{"id":31827921,"url":"https://github.com/ptlis/conneg","last_synced_at":"2025-10-11T19:20:33.162Z","repository":{"id":5728705,"uuid":"6940485","full_name":"ptlis/conneg","owner":"ptlis","description":"Content Negotiation for PHP","archived":false,"fork":false,"pushed_at":"2021-09-11T14:30:36.000Z","size":811,"stargazers_count":35,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-16T14:16:18.037Z","etag":null,"topics":["conneg","content-negotiation","php"],"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/ptlis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2012-11-30T14:44:19.000Z","updated_at":"2022-06-17T01:14:07.000Z","dependencies_parsed_at":"2022-09-05T08:30:35.146Z","dependency_job_id":null,"html_url":"https://github.com/ptlis/conneg","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ptlis/conneg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptlis%2Fconneg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptlis%2Fconneg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptlis%2Fconneg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptlis%2Fconneg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ptlis","download_url":"https://codeload.github.com/ptlis/conneg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptlis%2Fconneg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008466,"owners_count":26084460,"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-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["conneg","content-negotiation","php"],"created_at":"2025-10-11T19:20:32.278Z","updated_at":"2025-10-11T19:20:33.157Z","avatar_url":"https://github.com/ptlis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConNeg\n\nContent Negotiation for PHP.\n\nThis framework-independent library provides tooling to allow you to support content negotiation in your applications.\n\nSupports negotiation on the  [Accept](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1), [Accept-Charset](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2), [Accept-Encoding](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3) and [Accept-Language](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4) fields in a HTTP header.\n\n[![Build Status](https://api.travis-ci.com/ptlis/conneg.svg?branch=master)](https://app.travis-ci.com/github/ptlis/conneg) [![Code Coverage](https://scrutinizer-ci.com/g/ptlis/conneg/badges/coverage.png?s=6c30a32e78672ae0d7cff3ecf00ceba95049879a)](https://scrutinizer-ci.com/g/ptlis/conneg/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/ptlis/conneg/badges/quality-score.png?s=b8a262b33dd4a5de02d6f92f3e318ebb319f96c0)](https://scrutinizer-ci.com/g/ptlis/conneg/)  [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/ptlis/conneg/blob/master/LICENSE) [![Latest Stable Version](https://poser.pugx.org/ptlis/conneg/v/stable.png)](https://packagist.org/packages/ptlis/conneg)\n\n## Install\n\nWith composer:\n\n```shell\n$ composer require ptlis/conneg:~4.0.0\n```\n\n## Usage\n\n\n### In a PSR-7 Project\n\nIf your application supports PSR-7 then the simplest way to get content negotiation is via the middlewares provided by [ptlis/psr7-conneg](https://github.com/ptlis/psr7-conneg).\n\n\n### In non PSR-7 Projects\n\nFirst create a Negotiation instance. This provides methods to perform negotiation on client and server preferences.\n\n```php\nuse ptlis\\ConNeg\\Negotiation;\n\n$negotiation = new Negotiation();\n```\n\nIn most cases your application will only care about the best match, to get these we can use the ```*Best()``` methods.\n\nFor example, negotiation to decide whether to serve JSON or XML (preferring JSON) would look like:\n\n```php\n$bestMime = $negotiation-\u003emimeBest(\n    $_SERVER['ACCEPT'], \n    'application/json;q=1,application/xml;q=0.75'\n);\n```\n\nThis will return a string representation of the best matching mime-type specified by the server's preferences, for example 'application/json'.\n\nNegotiation of Language, Encoding \u0026 Charset can be done by using the appropriate method (languageBest, encodingBest \u0026 charsetBest respectively).\n\n**Note:** server preferences a string-encoded as described [in the documentation](http://ptlis.github.io/conneg/basics.html#type-preference-encodings).\n\nSee the [detailed usage docs](http://ptlis.github.io/conneg/usage.html) for further (more complex) examples.\n\n\n\n\n## Documentation\n\n[Full Documentation](http://ptlis.github.io/conneg/)\n\n## Integration\n\n* PSR-7 via the [ptlis/psr7-conneg](https://github.com/ptlis/psr7-conneg) package, with middlewares supporting:\n    * [Zend Stratigility](https://github.com/zendframework/zend-stratigility)\n    * [Relay](https://github.com/relayphp/Relay.Relay)\n* Symfony2 via the [ptlis/conneg-bundle](https://github.com/ptlis/conneg-bundle) Bundle.\n\n## Contributing\n\nYou can contribute by submitting an Issue to the [issue tracker](https://github.com/ptlis/conneg/issues), improving the [documentation](https://github.com/ptlis/conneg/tree/gh-pages), integrating the library into your framework of choice or submitting a pull request. For pull requests i'd prefer that the code style and test coverage is maintained, but I am happy to work through any minor issues that may arise so that the request can be merged.\n\n\n## TODO\n\n* Time based negotiation? See RFC 7089\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptlis%2Fconneg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fptlis%2Fconneg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptlis%2Fconneg/lists"}