PHP Classes

Just Http Status Codes: Constants for the most common HTTP status codes

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 66 All time: 10,365 This week: 47Up
Version License PHP version Categories
justhttpstatuscodes 1.0GNU General Publi...5HTTP, PHP 5
Description 

Author

This class provides constants for the most common HTTP status codes.

It is a class with several constant values with names of the HTTP response status codes.

Applications that need to return HTTP response status headers can just use this class and refer to the status codes using the class name followed by the respective HTTP status constant name, for instance StatusCode::NOT_FOUND instead of 404.

Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 48 packages by
Country: United Kingdom
Age: 33
All time rank: 37416 in United Kingdom
Week rank: 6 Up1 in United Kingdom Up
Innovation award
Innovation award
Nominee: 17x

Winner: 3x

Documentation

Just HTTP Status Codes

Just HTTP Status Codes is a great way to empower your project with clean practice ?

? Overview

Ko Fi - Offer Me A Coffee

Simplest. Clean. Efficient. Just what your project needs ?

Don't hardcode HTTP status codes. Magic numbers (hard-coded numbers) make your code hard to be read and understood.

When you have all status codes are stored in readable constants, it makes the development of your application so easy and enjoyable.

It prevents you of using the wrong HTTP status code and saves time and energy when developing an API that involves various HTTP status codes to be sent.

PHP HTTP Status Codes constants

? PHP Requirement

PHP v7.3 or newer ?

? Installation

composer require ph-7/just-http-status-codes

If you don't already use composer in your project, include Composer's autoload as below in the main index file, bootstrap or in another file that is always included in all pages.

require __DIR__ . '/vendor/autoload.php';

? Usage

Just use the beautiful HTTP status code you need.

Like below ?

use PH7\JustHttp\StatusCode;


StatusCode::OK; // This is 200

StatusCode::CREATED; // 201 code

StatusCode::NOT_FOUND; // 404

StatusCode::INTERNAL_SERVER_ERROR; // 500

? Who cooked it?

Pierre-Henry Soria

[![@phenrysay][twitter-image]](https://twitter.com/phenrysay) [![pH-7][github-image]](https://github.com/pH-7)

Pierre-Henry Soria, a highly passionate, zen &amp; pragmatic software engineer ?

??? Are you enjoying it? Offer me a coffee and boost the software development at the same time! ?

? Me building it

[![Watch the video][video-thumbnail]](https://www.youtube.com/watch?v=fK9K-UrLHNE)

? Click here to watch on YouTube

?? License

Just HTTP StatusCodes is generously distributed under the _MIT_ ? Enjoy!

<!-- GitHub's Markdown reference links --> [twitter-image]: https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white [github-image]: https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white [video-thumbnail]: https://i1.ytimg.com/vi/fK9K-UrLHNE/sddefault.jpg


  Files folder image Files (11)  
File Role Description
Files folder image.github (1 file, 1 directory)
Files folder imagemedia (1 file)
Files folder imagesrc (1 file)
Files folder imagetests (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Image file php-http-status-codes.png Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file save-code.sh Data Auxiliary data

  Files folder image Files (11)  /  .github  
File Role Description
Files folder imageworkflows (1 file)
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data

  Files folder image Files (11)  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test.yml Data Auxiliary data

  Files folder image Files (11)  /  media  
File Role Description
  Accessible without login Image file kofi-logo.png Icon Icon image

  Files folder image Files (11)  /  src  
File Role Description
  Plain text file StatusCode.php Class Class source

  Files folder image Files (11)  /  tests  
File Role Description
Files folder imageUnit (1 file)

  Files folder image Files (11)  /  tests  /  Unit  
File Role Description
  Plain text file StatusCodeTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:66
This week:0
All time:10,365
This week:47Up