PHP Classes

PHP HTTP Header Response: Send response headers to process HTTP requests

Recommend this page to a friend!
  Info   View files Documentation   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-06-09 (11 months ago) RSS 2.0 feedNot enough user ratingsTotal: 55 All time: 10,564 This week: 673Up
Version License PHP version Categories
php-http-header-resp 1.0GNU General Publi...8HTTP
Description 

Author

This package can send response headers to process HTTP requests.

It provides functions to generate and send HTTP response headers based on the HTTP status codes passed as parameters.

The package can also get the current request protocol to determine if it is HTTP or HTTPS.

It can also send the content type of the HTTP response.

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

Winner: 3x

Documentation

PHP HTTP Response

Send easily HTTP header responses to the browser.

Requirement

* PHP v8.0 or higher ?

Installation

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
Http::setHeadersByCode(200);

// ...

// Send "201 Created" header
Http::setHeadersByCode(201);

// ...

// Sends "404 Not Found" to the browser
Http::setHeadersByCode(404);

// ...

// Sends "400 Bad Request" header to the browser
Http::setHeadersByCode(400);


// 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
Http::getProtocol()

Set Content Type

use PH7\PhpHttpResponseHeader\Header;

// Send "Content-Type: application/json" header to the browser
Http::setContentType('application/json');

// Send "Content-type: text/xml" to the browser
Http::setContentType('text/xml');

??? 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 PH7.me ?

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

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

?? License

PHP HTTP Response 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


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (3 files)
Files folder imagetests (1 file)
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 Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

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

  Files folder image Files  /  src  
File Role Description
  Plain text file Exception.php Class Class source
  Plain text file Http.php Class Class source
  Plain text file Server.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file HttpTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:55
This week:0
All time:10,564
This week:673Up