PHPackages                             ph-7/php-http-response-header - 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. ph-7/php-http-response-header

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

ph-7/php-http-response-header
=============================

A simple package to send HTTP response headers from your PHP application

v1.0.4(1y ago)82432MITPHPPHP &gt;=8.0CI passing

Since Jun 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pH-7/php-http-header-response)[ Packagist](https://packagist.org/packages/ph-7/php-http-response-header)[ Docs](https://github.com/pH-7/php-http-header-response)[ GitHub Sponsors](https://github.com/pH-7)[ Fund](https://ko-fi.com/phenry)[ RSS](/packages/ph-7-php-http-response-header/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

PHP HTTP Response Headers
=========================

[](#php-http-response-headers)

**Simple PHP package to safely send the right HTTP header responses to the browser 🐘**

- [⚙️ Requirement](#%EF%B8%8F-requirement)
- [📦 Installation](#-installation)
- [🪄 Examples](#-usage---examples)
- [👨‍🍳 Who is the baker?](#-who-baked-this)
- [🎥 Me building this package](#-me-building-this-package)
- [⚖️ License](#%EF%B8%8F-license)

⚙️ Requirement
--------------

[](#️-requirement)

- [PHP v8.0](https://www.php.net/releases/8.0/en.php) or higher 🚀

📦 Installation
--------------

[](#-installation)

The simplest way to add this library to your project, is with [Composer](https://getcomposer.org).

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

🪄 Usage - Examples
------------------

[](#-usage---examples)

### Send Header By HTTP Code

[](#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

[](#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

[](#get-http-protocol)

```
use PH7\PhpHttpResponseHeader\Header;

//  The HTTP server protocol
Http::getProtocol()
```

### Set Content Type

[](#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?
-------------------

[](#‍-who-baked-this)

[![Pierre-Henry Soria](https://camo.githubusercontent.com/2e624b95003073bd56ecb43792155201b96f2e1d11bab1218e2215b6238c6ac2/68747470733a2f2f732e67726176617461722e636f6d2f6176617461722f61323130666536313235336334336338363964373165616564306539303134393f733d323030)](https://PH7.me "Pierre-Henry Soria personal website")

**Pierre-Henry Soria**. A super passionate and enthusiastic software engineer! 🚀 True cheese 🧀 , coffee, and chocolate lover! 😋 Reach me at [PH7.me](https://PH7.me) 💫

☕️ Are you enjoying it? **[Offer me a coffee](https://ko-fi.com/phenry)** (my favorite coffee to start the day is almond flat white 😋)

[![@phenrysay](https://camo.githubusercontent.com/d4158f0f6ed5d2434d8d9fce9258de955df14fc970066ddb62fe5451f57ab698/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f782d3030303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d78)](https://x.com/phenrysay) [![YouTube Tech Videos](https://camo.githubusercontent.com/6690f404cb91efe3927127c7dae40ed4f401c7d6fbe3ad3635b7ad9ba0b370c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f596f75547562652d4646303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d796f7574756265266c6f676f436f6c6f723d7768697465)](https://www.youtube.com/@pH7Programming "My YouTube Tech Channel") [![pH-7](https://camo.githubusercontent.com/4fcd516e2fde608afc9ddd1330de295d23981c27a9b9d695f8abe51f70a1efc5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769744875622d3130303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465)](https://github.com/pH-7)

🎥 Me building this package
--------------------------

[](#-me-building-this-package)

[![Watch the video](https://camo.githubusercontent.com/645436b51b5523a76137a674112e0a5432af570a9c4bf5f8e232371d982e2e3f/68747470733a2f2f69312e7974696d672e636f6d2f76692f5134646a7352637a78676f2f6d617872657364656661756c742e6a7067)](https://youtu.be/Q4djsRczxgo)

👉 **[Click here to watch on YouTube](https://youtu.be/Q4djsRczxgo)**, me building this package from A to Z.

---

[![PHP HTTP Response Headers - Send Header By HTTP Code](media/php-http-header-response.png)](media/php-http-header-response.png)

⚖️ License
----------

[](#️-license)

**PHP HTTP Response** is generously distributed under the *[MIT](https://opensource.org/licenses/MIT)* 🎉 Enjoy!

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance41

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~125 days

Total

5

Last Release

610d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6d95da236687f1dca4f7d70d60037c70ef217120ea195df23a39a412ba594e0?d=identicon)[ph-7](/maintainers/ph-7)

---

Top Contributors

[![pH-7](https://avatars.githubusercontent.com/u/1325411?v=4)](https://github.com/pH-7 "pH-7 (55 commits)")

---

Tags

headerhttphttp-codeshttp-headersphpphp-header-responsephp-headersphp-http-headershttpresponseheadersstatus codehttp statushttp-status-codehttp-responseHTTP-header

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ph-7-php-http-response-header/health.svg)

```
[![Health](https://phpackages.com/badges/ph-7-php-http-response-header/health.svg)](https://phpackages.com/packages/ph-7-php-http-response-header)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B3.7k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.0k1.1B6.5k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k728.6M2.5k](/packages/psr-http-factory)[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39394.6M297](/packages/fig-http-message-util)[nette/http

🌐 Nette Http: abstraction for HTTP request, response and session. Provides careful data sanitization and utility for URL and cookies manipulation.

49019.6M575](/packages/nette-http)[psr/http-server-handler

Common interface for HTTP server-side request handler

178109.8M1.1k](/packages/psr-http-server-handler)

PHPackages © 2026

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