PHPackages                             lukasoppermann/http-status - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. lukasoppermann/http-status

ActiveLibrary[HTTP &amp; Networking](/categories/http)

lukasoppermann/http-status
==========================

A minimal package for working with HTTP statuses.

4.0.0(2y ago)1061.1M—1.3%1120MITPHPPHP &gt;=5.3.0

Since Aug 3Pushed 2y ago5 watchersCompare

[ Source](https://github.com/lukasoppermann/http-status)[ Packagist](https://packagist.org/packages/lukasoppermann/http-status)[ Docs](https://github.com/lukasoppermann/http-status)[ RSS](/packages/lukasoppermann-http-status/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (24)Used By (20)

Httpstatus
==========

[](#httpstatus)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1df0cf02dbd80ca0ee3ca8d1eab69aec171f74f14370045928b26e2e8d7fef73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c756b61736f707065726d616e6e2f687474702d7374617475732e7376673f7374796c653d666c61742d737175617265)](https://github.com/lukasoppermann/http-status/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3fdb329f796f56475c33eabc3204c145489a3f87dd02f724622ed488cc458179/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c756b61736f707065726d616e6e2f687474702d7374617475732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/lukasoppermann/http-status)[![Build Status](https://camo.githubusercontent.com/8e2c6070d2acedd9392ebcd7b8289d56094b4c0016652a65441fa2727032f98b/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6c756b61736f707065726d616e6e2f687474702d7374617475732e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/lukasoppermann/http-status)[![Total Downloads](https://camo.githubusercontent.com/c097c732091e971578918797d2dddb969e8af811830258dc3348fdbf2cc65d5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c756b61736f707065726d616e6e2f687474702d7374617475732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lukasoppermann/http-status)

The 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`).

Install
-------

[](#install)

Via Composer

```
$ composer require lukasoppermann/http-status
```

Usage
-----

[](#usage)

```
$Httpstatus = new Lukasoppermann\Httpstatus\Httpstatus();

// (optional) specify language, default: en
$Httpstatus->setLanguage('en'); // Currently supported: en, fr

// get status text from code
echo $Httpstatus->getReasonPhrase(301); // Moved Permanently

// get the status code by text
echo $Httpstatus->getStatusCode('Method Not Allowed'); // 405

// check if status code exists
echo $Httpstatus->hasStatusCode(404); // true
echo $Httpstatus->hasStatusCode(601); // false

// check if reason phrase exists
echo $Httpstatus->hasReasonPhrase('Method Not Allowed'); // true
echo $Httpstatus->hasReasonPhrase('Does not exist'); // false

// determine the type (or "class") of the code
echo $Httpstatus->getResponseClass(503); // Httpstatus::CLASS_SERVER_ERROR
```

This 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.

```
use Lukasoppermann\Httpstatus\Httpstatuscodes;

class Response implements Httpstatuscodes{

  public function someMethod(){
      // ... some logic
      return respond(self::HTTP_CREATED, $json);
  }

}
```

It is also possible to directly use a constant from the Interface if you so desire.

```
use Lukasoppermann\Httpstatus\Httpstatuscodes as Status;

class UserTest{

  public function test_create_new_user(){
      $this->assertEquals(Status::HTTP_CREATED, $response->status());
  }

}
```

Configure
---------

[](#configure)

If you want to localize status texts, you can supply an array when initiating the class. You may overwrite all or just some codes. A reason phrase has to be unique and may only be used for one status code.

```
// add custom texts
$Httpstatus = new Lukasoppermann\Httpstatus\Httpstatus([
    200 => 'Kein Inhalt',
    404 => 'Nicht gefunden',
]);
```

HTTP status code classes ([from RFC7231](https://tools.ietf.org/html/rfc7231#section-6))
----------------------------------------------------------------------------------------

[](#http-status-code-classes-from-rfc7231)

The first digit of the status-code defines the class of response. The last two digits do not have any categorization role. There are five values for the first digit:

DigitCategoryMeaning1xxInformationalThe request was received, continuing process2xxSuccessfulThe request was successfully received, understood, and accepted3xxRedirectionFurther action needs to be taken in order to complete the request4xxClient ErrorThe request contains bad syntax or cannot be fulfilled5xxServer ErrorThe server failed to fulfill an apparently valid requestAvailable HTTP status codes
---------------------------

[](#available-http-status-codes)

CodeMessageRFC100Continue\[RFC7231, Section 6.2.1\]101Switching Protocols\[RFC7231, Section 6.2.2\]102Processing\[RFC2518\]103-199*Unassigned*200OK\[RFC7231, Section 6.3.1\]201Created\[RFC7231, Section 6.3.2\]202Accepted\[RFC7231, Section 6.3.3\]203Non-Authoritative Information\[RFC7231, Section 6.3.4\]204No Content\[RFC7231, Section 6.3.5\]205Reset Content\[RFC7231, Section 6.3.6\]206Partial Content\[RFC7233, Section 4.1\]207Multi-Status\[RFC4918\]208Already Reported\[RFC5842\]209-225*Unassigned*226IM Used\[RFC3229\]227-299*Unassigned*300Multiple Choices\[RFC7231, Section 6.4.1\]301Moved Permanently\[RFC7231, Section 6.4.2\]302Found\[RFC7231, Section 6.4.3\]303See Other\[RFC7231, Section 6.4.4\]304Not Modified\[RFC7232, Section 4.1\]305Use Proxy\[RFC7231, Section 6.4.5\]306(Unused)\[RFC7231, Section 6.4.6\]307Temporary Redirect\[RFC7231, Section 6.4.7\]308Permanent Redirect\[RFC7538\]309-399*Unassigned*400Bad Request\[RFC7231, Section 6.5.1\]401Unauthorized\[RFC7235, Section 3.1\]402Payment Required\[RFC7231, Section 6.5.2\]403Forbidden\[RFC7231, Section 6.5.3\]404Not Found\[RFC7231, Section 6.5.4\]405Method Not Allowed\[RFC7231, Section 6.5.5\]406Not Acceptable\[RFC7231, Section 6.5.6\]407Proxy Authentication Required\[RFC7235, Section 3.2\]408Request Timeout\[RFC7231, Section 6.5.7\]409Conflict\[RFC7231, Section 6.5.8\]410Gone\[RFC7231, Section 6.5.9\]411Length Required\[RFC7231, Section 6.5.10\]412Precondition Failed\[RFC7232, Section 4.2\]413Payload Too Large\[RFC7231, Section 6.5.11\]414URI Too Long\[RFC7231, Section 6.5.12\]415Unsupported Media Type\[RFC7231, Section 6.5.13\]416Range Not Satisfiable\[RFC7233, Section 4.4\]417Expectation Failed\[RFC7231, Section 6.5.14\]418I'm a teapot\[RFC2324, Section 2.3.2\]419-420*Unassigned*421Misdirected Request\[RFC7540, Section 9.1.2\]422Unprocessable Entity\[RFC4918\]423Locked\[RFC4918\]424Failed Dependency\[RFC4918\]425Too Early\[RFC8740, Section 5.2\]426Upgrade Required\[RFC7231, Section 6.5.15\]427*Unassigned*428Precondition Required\[RFC6585\]429Too Many Requests\[RFC6585\]430*Unassigned*431Request Header Fields Too Large\[RFC6585\]432-499*Unassigned*500Internal Server Error\[RFC7231, Section 6.6.1\]501Not Implemented\[RFC7231, Section 6.6.2\]502Bad Gateway\[RFC7231, Section 6.6.3\]503Service Unavailable\[RFC7231, Section 6.6.4\]504Gateway Timeout\[RFC7231, Section 6.6.5\]505HTTP Version Not Supported\[RFC7231, Section 6.6.6\]506Variant Also Negotiates\[RFC2295\]507Insufficient Storage\[RFC4918\]508Loop Detected\[RFC5842\]509*Unassigned*510Not Extended\[RFC2774\]511Network Authentication Required\[RFC6585\]512-599*Unassigned*Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lukas Oppermann](https://github.com/lukasoppermann)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~151 days

Recently: every ~141 days

Total

20

Last Release

1060d ago

Major Versions

0.9.7 → 1.0.02015-09-01

1.0.1 → 2.0.02016-07-10

2.0.1 → 3.0.02020-11-04

3.3.0 → 4.0.02023-06-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/679b4f6aab04e0eafb535b2cd2d15d2ec9626fb4ba3f7cdb9eb679f528547121?d=identicon)[lukasoppermann](/maintainers/lukasoppermann)

---

Top Contributors

[![lukasoppermann](https://avatars.githubusercontent.com/u/813754?v=4)](https://github.com/lukasoppermann "lukasoppermann (13 commits)")[![Herz3h](https://avatars.githubusercontent.com/u/1900696?v=4)](https://github.com/Herz3h "Herz3h (9 commits)")[![nyamsprod](https://avatars.githubusercontent.com/u/51073?v=4)](https://github.com/nyamsprod "nyamsprod (8 commits)")[![colinodell](https://avatars.githubusercontent.com/u/202034?v=4)](https://github.com/colinodell "colinodell (4 commits)")[![MaelImhof](https://avatars.githubusercontent.com/u/46901347?v=4)](https://github.com/MaelImhof "MaelImhof (2 commits)")[![edamov](https://avatars.githubusercontent.com/u/2741880?v=4)](https://github.com/edamov "edamov (2 commits)")[![onanying](https://avatars.githubusercontent.com/u/16074765?v=4)](https://github.com/onanying "onanying (2 commits)")[![pavelskipenes](https://avatars.githubusercontent.com/u/38912521?v=4)](https://github.com/pavelskipenes "pavelskipenes (1 commits)")[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (1 commits)")[![SMillerDev](https://avatars.githubusercontent.com/u/1484494?v=4)](https://github.com/SMillerDev "SMillerDev (1 commits)")

---

Tags

httpstatusphphttpstatusstatus codes

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/lukasoppermann-http-status/health.svg)

```
[![Health](https://phpackages.com/badges/lukasoppermann-http-status/health.svg)](https://phpackages.com/packages/lukasoppermann-http-status)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
