{"id":16584230,"url":"https://github.com/lukasoppermann/http-status","last_synced_at":"2025-04-05T07:04:12.383Z","repository":{"id":35758091,"uuid":"40037370","full_name":"lukasoppermann/http-status","owner":"lukasoppermann","description":"A minimal package for working with HTTP statuses.","archived":false,"fork":false,"pushed_at":"2023-06-23T18:40:58.000Z","size":95,"stargazers_count":109,"open_issues_count":0,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-12T22:44:20.015Z","etag":null,"topics":["httpstatus","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/lukasoppermann/http-status","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/lukasoppermann.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2015-08-01T06:13:44.000Z","updated_at":"2024-05-26T11:58:41.000Z","dependencies_parsed_at":"2024-10-25T18:29:34.404Z","dependency_job_id":"307a05cf-b692-4e86-8da6-d5a5d603b115","html_url":"https://github.com/lukasoppermann/http-status","commit_stats":{"total_commits":54,"total_committers":14,"mean_commits":3.857142857142857,"dds":0.7222222222222222,"last_synced_commit":"8ef0326965cee820293071604990c83577ebf4de"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasoppermann%2Fhttp-status","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasoppermann%2Fhttp-status/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasoppermann%2Fhttp-status/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasoppermann%2Fhttp-status/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukasoppermann","download_url":"https://codeload.github.com/lukasoppermann/http-status/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299831,"owners_count":20916190,"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":["httpstatus","php"],"created_at":"2024-10-11T22:44:13.890Z","updated_at":"2025-04-05T07:04:12.364Z","avatar_url":"https://github.com/lukasoppermann.png","language":"PHP","readme":"# Httpstatus\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/lukasoppermann/http-status.svg?style=flat-square)](https://github.com/lukasoppermann/http-status/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/lukasoppermann/http-status.svg?style=flat-square)](https://travis-ci.org/lukasoppermann/http-status)\n[![Build Status](https://img.shields.io/coveralls/lukasoppermann/http-status.svg?style=flat-square)](https://coveralls.io/github/lukasoppermann/http-status)\n[![Total Downloads](https://img.shields.io/packagist/dt/lukasoppermann/http-status.svg?style=flat-square)](https://packagist.org/packages/lukasoppermann/http-status)\n\nThe Httpstatus package provides an easy and convinent way to retrieve the standard status text (english) for any given HTTP status code. You can also get the HTTP status code for any valid status text. Additionally this package provides all status codes as constants, to use for a better readability of your code (`HTTP_OK` is just much easier to understand than `200`).\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require lukasoppermann/http-status\n```\n\n## Usage\n\n```php\n$Httpstatus = new Lukasoppermann\\Httpstatus\\Httpstatus();\n\n// (optional) specify language, default: en\n$Httpstatus-\u003esetLanguage('en'); // Currently supported: en, fr\n\n// get status text from code\necho $Httpstatus-\u003egetReasonPhrase(301); // Moved Permanently\n\n// get the status code by text\necho $Httpstatus-\u003egetStatusCode('Method Not Allowed'); // 405\n\n// check if status code exists\necho $Httpstatus-\u003ehasStatusCode(404); // true\necho $Httpstatus-\u003ehasStatusCode(601); // false\n\n// check if reason phrase exists\necho $Httpstatus-\u003ehasReasonPhrase('Method Not Allowed'); // true\necho $Httpstatus-\u003ehasReasonPhrase('Does not exist'); // false\n\n// determine the type (or \"class\") of the code\necho $Httpstatus-\u003egetResponseClass(503); // Httpstatus::CLASS_SERVER_ERROR\n```\n\nThis package provides an interface with all status codes as constanst for your convenience. When developing a class that deals with HTTP status codes, simply implement the interface and start using constants instead of magic numbers for more readable and understandable code.\n\n```php\nuse Lukasoppermann\\Httpstatus\\Httpstatuscodes;\n\nclass Response implements Httpstatuscodes{\n\n  public function someMethod(){\n      // ... some logic\n      return respond(self::HTTP_CREATED, $json);\n  }\n\n}\n```\n\nIt is also possible to directly use a constant from the Interface if you so desire.\n\n```php\nuse Lukasoppermann\\Httpstatus\\Httpstatuscodes as Status;\n\nclass UserTest{\n\n  public function test_create_new_user(){\n      $this-\u003eassertEquals(Status::HTTP_CREATED, $response-\u003estatus());\n  }\n\n}\n```\n\n## Configure\nIf you want to localize status texts, you can supply an array when initiating the class. You may overwrite all or just some codes.\nA reason phrase has to be unique and may only be used for one status code.\n\n``` php\n// add custom texts\n$Httpstatus = new Lukasoppermann\\Httpstatus\\Httpstatus([\n    200 =\u003e 'Kein Inhalt',\n    404 =\u003e 'Nicht gefunden',\n]);\n```\n\n## HTTP status code classes ([from RFC7231](https://tools.ietf.org/html/rfc7231#section-6))\nThe first digit of the status-code defines the class of response.\nThe last two digits do not have any categorization role. There are five values for the first digit:\n\nDigit  |  Category  |  Meaning\n------------- | -------------  | -------------\n1xx | Informational | The request was received, continuing process\n2xx | Successful | The request was successfully received, understood, and accepted\n3xx | Redirection | Further action needs to be taken in order to complete the request\n4xx | Client Error | The request contains bad syntax or cannot be fulfilled\n5xx | Server Error | The server failed to fulfill an apparently valid request\n\n\n## Available HTTP status codes\nCode  |  Message  |  RFC\n------------- | ------------- | -------------\n100 | Continue | [RFC7231, Section 6.2.1]\n101 | Switching Protocols | [RFC7231, Section 6.2.2]\n102 | Processing | [RFC2518]\n103-199 | *Unassigned* |\n200 | OK | [RFC7231, Section 6.3.1]\n201 | Created | [RFC7231, Section 6.3.2]\n202 | Accepted | [RFC7231, Section 6.3.3]\n203 | Non-Authoritative Information | [RFC7231, Section 6.3.4]\n204 | No Content | [RFC7231, Section 6.3.5]\n205 | Reset Content | [RFC7231, Section 6.3.6]\n206 | Partial Content | [RFC7233, Section 4.1]\n207 | Multi-Status | [RFC4918]\n208 | Already Reported | [RFC5842]\n209-225 | *Unassigned* |\n226 | IM Used | [RFC3229]\n227-299 | *Unassigned* |\n300 | Multiple Choices | [RFC7231, Section 6.4.1]\n301 | Moved Permanently | [RFC7231, Section 6.4.2]\n302 | Found | [RFC7231, Section 6.4.3]\n303 | See Other | [RFC7231, Section 6.4.4]\n304 | Not Modified | [RFC7232, Section 4.1]\n305 | Use Proxy | [RFC7231, Section 6.4.5]\n306 | (Unused) | [RFC7231, Section 6.4.6]\n307 | Temporary Redirect | [RFC7231, Section 6.4.7]\n308 | Permanent Redirect | [RFC7538]\n309-399 | *Unassigned* |\n400 | Bad Request | [RFC7231, Section 6.5.1]\n401 | Unauthorized | [RFC7235, Section 3.1]\n402 | Payment Required | [RFC7231, Section 6.5.2]\n403 | Forbidden | [RFC7231, Section 6.5.3]\n404 | Not Found | [RFC7231, Section 6.5.4]\n405 | Method Not Allowed | [RFC7231, Section 6.5.5]\n406 | Not Acceptable | [RFC7231, Section 6.5.6]\n407 | Proxy Authentication Required | [RFC7235, Section 3.2]\n408 | Request Timeout | [RFC7231, Section 6.5.7]\n409 | Conflict | [RFC7231, Section 6.5.8]\n410 | Gone | [RFC7231, Section 6.5.9]\n411 | Length Required | [RFC7231, Section 6.5.10]\n412 | Precondition Failed | [RFC7232, Section 4.2]\n413 | Payload Too Large | [RFC7231, Section 6.5.11]\n414 | URI Too Long | [RFC7231, Section 6.5.12]\n415 | Unsupported Media Type | [RFC7231, Section 6.5.13]\n416 | Range Not Satisfiable | [RFC7233, Section 4.4]\n417 | Expectation Failed | [RFC7231, Section 6.5.14]\n418 | I'm a teapot | [RFC2324, Section 2.3.2]\n419-420 | *Unassigned* |\n421 | Misdirected Request | [RFC7540, Section 9.1.2]\n422 | Unprocessable Entity | [RFC4918]\n423 | Locked | [RFC4918]\n424 | Failed Dependency | [RFC4918]\n425 | Too Early | [RFC8740, Section 5.2]\n426 | Upgrade Required | [RFC7231, Section 6.5.15]\n427 | *Unassigned* |\n428 | Precondition Required | [RFC6585]\n429 | Too Many Requests | [RFC6585]\n430 | *Unassigned* |\n431 | Request Header Fields Too Large | [RFC6585]\n432-499 | *Unassigned* |\n500 | Internal Server Error | [RFC7231, Section 6.6.1]\n501 | Not Implemented | [RFC7231, Section 6.6.2]\n502 | Bad Gateway | [RFC7231, Section 6.6.3]\n503 | Service Unavailable | [RFC7231, Section 6.6.4]\n504 | Gateway Timeout | [RFC7231, Section 6.6.5]\n505 | HTTP Version Not Supported | [RFC7231, Section 6.6.6]\n506 | Variant Also Negotiates | [RFC2295]\n507 | Insufficient Storage | [RFC4918]\n508 | Loop Detected | [RFC5842]\n509 | *Unassigned* |\n510 | Not Extended | [RFC2774]\n511 | Network Authentication Required | [RFC6585]\n512-599 | *Unassigned* |\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email oppermann.lukas@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Lukas Oppermann][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[link-author]: https://github.com/lukasoppermann\n[link-contributors]: ../../contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasoppermann%2Fhttp-status","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukasoppermann%2Fhttp-status","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasoppermann%2Fhttp-status/lists"}