PHP Classes


Recommend this page to a friend!
  Classes of Pierre-Henry Soria   PHP HTTP Header Response   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP HTTP Header Response
Send response headers to process HTTP requests
Author: By
Last change:
Date: 1 year ago
Size: 2,447 bytes


Class file image Download

PHP HTTP Response

Send easily HTTP header responses to the browser.


* PHP v8.0 or higher ?


The simplest way to add this library to your project, is with Composer

composer require ph-7/php-http-response-header

? Usage - Examples

Send Header By HTTP Code

use PH7\PhpHttpResponseHeader\Header;

// Sends "200 OK" header to the browser

// ...

// Send "201 Created" header

// ...

// Sends "404 Not Found" to the browser

// ...

// Sends "400 Bad Request" header to the browser

// and so on ...

But, the library has many more handy methods such as below:

Maintenance Code

use PH7\PhpHttpResponseHeader\Header;

// Send 503, Service Temporarily Unavailable to the browser mentioning that you are doing a maintenance (good practice!)
Http::setMaintenanceCode($maintenanceTimeSeconds: 360);

Get HTTP Protocol

use PH7\PhpHttpResponseHeader\Header;

//  The HTTP server protocol

Set Content Type

use PH7\PhpHttpResponseHeader\Header;

// Send "Content-Type: application/json" header to the browser

// Send "Content-type: text/xml" to the browser

??? Who baked this?

Pierre-Henry Soria

Pierre-Henry Soria. A super passionate and enthusiastic software engineer! ? True cheese ? , coffee, and chocolate lover! ? Reach me at ?

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

[![@phenrysay][twitter-image]]( [![pH-7][github-image]](

?? License

PHP HTTP Response is generously distributed under the _MIT_ ? Enjoy!

<!-- GitHub's Markdown reference links --> [twitter-image]: [github-image]: