PHPackages                             scaleplan/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. scaleplan/http-status

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

scaleplan/http-status
=====================

A minimal package for working with HTTP statuses.

3.0.0(7y ago)0411PHPPHP &gt;=7.2

Since Aug 3Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (17)Used By (1)

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();

// 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\]425Reserved for WebDAV advanced collections expired proposal426Upgrade 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

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

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 ~102 days

Recently: every ~325 days

Total

14

Last Release

2607d ago

Major Versions

0.9.7 → 1.0.02015-09-01

1.0.1 → 2.0.02016-07-10

2.0.1 → 3.0.02019-03-27

PHP version history (2 changes)0.9.0PHP &gt;=5.3.0

3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10077243?v=4)[Aleksandr Avtomonov](/maintainers/avtomon)[@avtomon](https://github.com/avtomon)

---

Top Contributors

[![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)")[![edamov](https://avatars.githubusercontent.com/u/2741880?v=4)](https://github.com/edamov "edamov (2 commits)")[![avtomon](https://avatars.githubusercontent.com/u/10077243?v=4)](https://github.com/avtomon "avtomon (1 commits)")[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (1 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/scaleplan-http-status/health.svg)](https://phpackages.com/packages/scaleplan-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)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

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

78126.4M414](/packages/react-http)

PHPackages © 2026

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