{"id":15022096,"url":"https://github.com/josantonius/php-http-status-code","last_synced_at":"2025-04-12T06:06:39.537Z","repository":{"id":50624029,"uuid":"76822293","full_name":"josantonius/php-http-status-code","owner":"josantonius","description":"PHP library to get HTTP status code definitions","archived":false,"fork":false,"pushed_at":"2022-09-29T16:54:34.000Z","size":1205,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T06:06:18.378Z","etag":null,"topics":["composer","http-status-code","http-status-codes","php"],"latest_commit_sha":null,"homepage":"https://josantonius.dev","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/josantonius.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["Josantonius"]}},"created_at":"2016-12-19T02:47:48.000Z","updated_at":"2024-06-07T08:57:59.000Z","dependencies_parsed_at":"2022-09-22T14:25:00.273Z","dependency_job_id":null,"html_url":"https://github.com/josantonius/php-http-status-code","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-http-status-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-http-status-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-http-status-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-http-status-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josantonius","download_url":"https://codeload.github.com/josantonius/php-http-status-code/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525145,"owners_count":21118618,"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":["composer","http-status-code","http-status-codes","php"],"created_at":"2024-09-24T19:57:27.148Z","updated_at":"2025-04-12T06:06:39.509Z","avatar_url":"https://github.com/josantonius.png","language":"PHP","readme":"# PHP HTTP Status Code library\n\n[![Latest Stable Version](https://poser.pugx.org/josantonius/http-status-code/v/stable)](https://packagist.org/packages/josantonius/http-status-code)\n[![License](https://poser.pugx.org/josantonius/http-status-code/license)](LICENSE)\n[![Total Downloads](https://poser.pugx.org/josantonius/http-status-code/downloads)](https://packagist.org/packages/josantonius/http-status-code)\n[![CI](https://github.com/josantonius/php-http-status-code/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/josantonius/php-http-status-code/actions/workflows/ci.yml)\n[![CodeCov](https://codecov.io/gh/josantonius/php-http-status-code/branch/main/graph/badge.svg)](https://codecov.io/gh/josantonius/php-http-status-code)\n[![PSR1](https://img.shields.io/badge/PSR-1-f57046.svg)](https://www.php-fig.org/psr/psr-1/)\n[![PSR4](https://img.shields.io/badge/PSR-4-9b59b6.svg)](https://www.php-fig.org/psr/psr-4/)\n[![PSR12](https://img.shields.io/badge/PSR-12-1abc9c.svg)](https://www.php-fig.org/psr/psr-12/)\n\n**Translations**: [Español](.github/lang/es-ES/README.md)\n\nPHP library to get HTTP status code messages and definitions.\n\n---\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Available Classes](#available-classes)\n  - [HttpStatusCode Class](#httpstatuscode-class)\n- [Exceptions Used](#exceptions-used)\n- [Usage](#usage)\n- [List in JSON format](#list-in-json-format)\n- [Tests](#tests)\n- [TODO](#todo)\n- [Changelog](#changelog)\n- [Contribution](#contribution)\n- [Sponsor](#sponsor)\n- [License](#license)\n\n---\n\n## Requirements\n\n- Operating System: Linux | Windows.\n\n- PHP versions: 8.0 | 8.1 | 8.2.\n\n## Installation\n\nThe preferred way to install this extension is through [Composer](http://getcomposer.org/download/).\n\nTo install **PHP HTTP Status Code library**, simply:\n\n```console\ncomposer require josantonius/http-status-code\n```\n\nThe previous command will only install the necessary files,\nif you prefer to **download the entire source code** you can use:\n\n```console\ncomposer require josantonius/http-status-code --prefer-source\n```\n\nYou can also **clone the complete repository** with Git:\n\n```console\ngit clone https://github.com/josantonius/http-status-code.git\n```\n\n## Available Classes\n\n### HttpStatusCode Class\n\n`Josantonius\\HttpStatusCode\\HttpStatusCode`\n\nCreate a new instance defining the language:\n\n```php\n/**\n * @param string $language The language in which the data will be retrieved.\n *\n *                         Available languages: en (English)\n *                                              es (Spanish)\n * \n * @throws UnsupportedLanguageException if language is not supported.\n */\npublic function __construct(string $language = 'en');\n```\n\nGets message of an HTTP status code:\n\n```php\npublic function getMessage(int $code): string|null;\n```\n\nGets the messages of all HTTP status codes:\n\n```php\npublic function getMessages(): array;\n```\n\nGets definition of an HTTP status code:\n\n```php\npublic function getDefinition(int $code): string|null;\n```\n\nGets the definitions of all HTTP status codes:\n\n```php\npublic function getDefinitions(): array;\n```\n\nGets messages and definitions of all HTTP status codes:\n\n```php\npublic function getAll(): array;\n```\n\n## Exceptions Used\n\n```php\nuse Josantonius\\HttpStatusCode\\UnsupportedLanguageException;\n```\n\n## Usage\n\nExample of use for this library:\n\n### Create a new instance defining the language\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode();     // Gets the messages in English.\n```\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode('es'); // Gets the messages in Spanish.\n```\n\n### Gets message of an HTTP status code\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode();\n\n$httpStatusCode-\u003egetMessage(404);\n```\n\nReturns:\n\n```php\n'Not Found'\n```\n\n### Gets the messages of all HTTP status codes\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode();\n\n$httpStatusCode-\u003egetMessages();\n```\n\nReturns:\n\n```php\n[\n    100 =\u003e 'Continue',\n    101 =\u003e 'Switching Protocols',\n    102 =\u003e 'Processing',\n\n    (...)\n]\n```\n\n### Gets definition of an HTTP status code\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode();\n\n$httpStatusCode-\u003egetDefinition(404);\n```\n\nReturns:\n\n```php\n'The requested resource could not be found but (...)'\n```\n\n### Gets the definitions of all HTTP status codes\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode();\n\n$httpStatusCode-\u003egetDefinitions();\n```\n\nReturns:\n\n```php\n[\n    100 =\u003e 'The server has received the request (...)',\n    101 =\u003e 'The requester has asked the server (...)',\n    102 =\u003e 'A WebDAV request may contain many (...)',\n\n    (...)\n]\n```\n\n### Gets messages and definitions of all HTTP status codes\n\n```php\nuse Josantonius\\HttpStatusCode\\HttpStatusCode;\n\n$httpStatusCode = new HttpStatusCode();\n\n$httpStatusCode-\u003egetAll();\n```\n\n```php\n[\n    100 =\u003e [\n        'message'    =\u003e 'Continue',\n        'definition' =\u003e 'The server has received the request (...)',\n    ],\n    101 =\u003e [\n        'message'    =\u003e 'Switching Protocols',\n        'definition' =\u003e 'The requester has asked the server (...)',\n    ],\n    102 =\u003e [\n        'message'    =\u003e 'Processing',\n        'definition' =\u003e 'A WebDAV request may contain many (...)',\n    ],\n\n    (...)\n]\n```\n\n## List in JSON format\n\n\u003chttps://gist.github.com/Josantonius/0a889ab6f18db2fcefda15a039613293\u003e\n\n## Tests\n\nTo run [tests](tests) you just need [composer](http://getcomposer.org/download/)\nand to execute the following:\n\n```console\ngit clone https://github.com/josantonius/php-http-status-code.git\n```\n\n```console\ncd php-http-status-code\n```\n\n```console\ncomposer install\n```\n\nRun unit tests with [PHPUnit](https://phpunit.de/):\n\n```console\ncomposer phpunit\n```\n\nRun code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):\n\n```console\ncomposer phpcs\n```\n\nRun [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:\n\n```console\ncomposer phpmd\n```\n\nRun all previous tests:\n\n```console\ncomposer tests\n```\n\n## TODO\n\n- [ ] Add new feature\n- [ ] Improve tests\n- [ ] Improve documentation\n- [ ] Improve English translation in the README file\n- [ ] Refactor code for disabled code style rules (see phpmd.xml and phpcs.xml)\n\n## Changelog\n\nDetailed changes for each release are documented in the\n[release notes](https://github.com/josantonius/php-http-status-code/releases).\n\n## Contribution\n\nPlease make sure to read the [Contributing Guide](.github/CONTRIBUTING.md), before making a pull\nrequest, start a discussion or report a issue.\n\nThanks to all [contributors](https://github.com/josantonius/php-http-status-code/graphs/contributors)! :heart:\n\n## Sponsor\n\nIf this project helps you to reduce your development time,\n[you can sponsor me](https://github.com/josantonius#sponsor) to support my open source work :blush:\n\n## License\n\nThis repository is licensed under the [MIT License](LICENSE).\n\nCopyright © 2016-present, [Josantonius](https://github.com/josantonius#contact)\n","funding_links":["https://github.com/sponsors/Josantonius"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosantonius%2Fphp-http-status-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosantonius%2Fphp-http-status-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosantonius%2Fphp-http-status-code/lists"}