{"id":20941069,"url":"https://github.com/lmc-eu/http-constants","last_synced_at":"2025-05-13T23:31:05.175Z","repository":{"id":53510776,"uuid":"98189833","full_name":"lmc-eu/http-constants","owner":"lmc-eu","description":"The missing PHP constants for HTTP header fields","archived":false,"fork":false,"pushed_at":"2023-01-24T14:00:38.000Z","size":37,"stargazers_count":25,"open_issues_count":2,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-11-14T20:49:25.785Z","etag":null,"topics":["constants","guzzle","http","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/lmc-eu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-24T12:46:53.000Z","updated_at":"2024-09-23T02:43:30.000Z","dependencies_parsed_at":"2023-02-13T22:00:18.742Z","dependency_job_id":null,"html_url":"https://github.com/lmc-eu/http-constants","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmc-eu%2Fhttp-constants","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmc-eu%2Fhttp-constants/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmc-eu%2Fhttp-constants/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmc-eu%2Fhttp-constants/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lmc-eu","download_url":"https://codeload.github.com/lmc-eu/http-constants/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225265006,"owners_count":17446757,"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":["constants","guzzle","http","php"],"created_at":"2024-11-18T23:12:44.012Z","updated_at":"2024-11-18T23:12:44.615Z","avatar_url":"https://github.com/lmc-eu.png","language":"PHP","readme":"# HTTP Header Fields Constants for PHP\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/lmc/http-constants.svg?style=flat-square)](https://packagist.org/packages/lmc/http-constants)\n[![GitHub Actions Build Status](https://img.shields.io/github/actions/workflow/status/lmc-eu/http-constants/tests.yaml?style=flat-square)](https://github.com/lmc-eu/http-constants/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/lmc/http-constants.svg?style=flat-square)](https://packagist.org/packages/lmc/http-constants)\n\nThe missing PHP constants definition for header fields of your HTTP requests and responses. \n\nStop repeating string identifiers and placing typos of HTTP headers in your code!\n\nCould be used when interacting with headers using [pure PHP], [Guzzle], [Symfony HttpFoundation], [Zend HTTP], [Zend Diactoros] etc.\n\nContains all ~200 constants for headers defined in [IANA list] (both Permanent and Provisional) and some common non-standard headers based on [Wikipedia list].\n\n## Install\n\n```sh\n$ composer require lmc/http-constants\n```\n\nNote you will need to have [Composer](https://getcomposer.org/) installed to do this.\n\n## Usage\n\n```php\n\u003c?php\n\nnamespace My;\n\nuse Lmc\\HttpConstants\\Header;\n\nclass Example\n{\n    public function exampleWithGuzzle()\n    {\n        $client = new \\GuzzleHttp\\Client();\n        \n        $response = $client-\u003erequest(\n            'GET',\n            'https://api.foo/bar',\n             ['headers' =\u003e [Header::ACCEPT_ENCODING =\u003e 'gzip']]\n       );\n\n        echo $response-\u003egetHeaderLine(Header::CONTENT_TYPE);\n    }\n\n    public function exampleWithSymfonyHttpFoundation()\n    {\n        $response = new \\Symfony\\Component\\HttpFoundation\\Response();\n            \n        $response-\u003eheaders-\u003eset(Header::ACCESS_CONTROL_ALLOW_ORIGIN, 'www.jobs.cz');\n    }\n\n    public function exampleWithPurePhp()\n    {\n        header(Header::CONTENT_TYPE . ': application/pdf');\n        header(Header::CACHE_CONTROL .  ': no-cache, must-revalidate');\n    }\n}\n\n```\n\n## Changelog\nFor latest changes see [CHANGELOG.md](CHANGELOG.md) file. We follow [Semantic Versioning](http://semver.org/).\n\n## License\nThe library is open source software licensed under the [MIT license](LICENCE.md).\n\n[pure PHP]: https://www.php.net/manual/en/function.header.php\n[Guzzle]: https://github.com/guzzle/guzzle\n[Symfony HttpFoundation]: https://symfony.com/doc/current/components/http_foundation.html\n[Zend HTTP]: https://zendframework.github.io/zend-http/\n[Zend Diactoros]: https://zendframework.github.io/zend-diactoros/\n[IANA list]: https://www.iana.org/assignments/message-headers/message-headers.xml\n[Wikipedia list]: https://en.wikipedia.org/wiki/List_of_HTTP_header_fields\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmc-eu%2Fhttp-constants","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flmc-eu%2Fhttp-constants","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmc-eu%2Fhttp-constants/lists"}