A simple package to send HTTP header responses ✨

Overview

PHP HTTP Response

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

Requirement

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 pH-7

βš–οΈ License

PHP HTTP Response is generously distributed under the MIT πŸŽ‰ Enjoy!

You might also like...
Simple HTTP smoke testing for your Symfony application

Shopsys HTTP Smoke Testing This package enables you to do simple HTTP smoke testing of your Symfony application. Basically, it generates a HTTP reques

⚑️ A WordPress plugin to quickly send a 404 for missing static files

Static 404 A WordPress plugin to quickly send a 404 for missing static files. Quickly output a 404 for static files that aren't found, rather than loa

A Kimai 2 plugin, which send duration of cards to GitLab spend issues of timesheet.
A Kimai 2 plugin, which send duration of cards to GitLab spend issues of timesheet.

GitLabBundle A Kimai 2 plugin, which send duration of cards to GitLab spend issues of timesheet. Installation First clone it to your Kimai installatio

Send tokens using PHP

Waiting vs Not Waiting The $transactionCount obtained by calling getTransactionCount() is only accurate if ALL the previously submitted transactions h

> Create e-wallet, send money, withdraw and check balance all via USSD protocol
Create e-wallet, send money, withdraw and check balance all via USSD protocol

Mobile Money USSD solution Create e-wallet, send money, withdraw and check balance all via USSD protocol Create e-wallet Step 1 Step 2 Step 3 Step 4 S

Send your laravel apps to the moon with web3 enabled πŸš€

Laravel Web3 πŸš€ 🌝 Laravel Web3 helps you to kickstart your web3 apps. No more headache with handling wallet changing address and sync with laravel ba

UpDown is an uptime monitor, We send out notifications when something's wrong.

About UpDown Updown is an uptime monitor, We send out notifications when something's wrong. Be the first to know that your website is down! Reliable m

An easy code to send messages on a discord text channel with webhook.

Status Webhook-Discord An easy code to send messages on a discord text channel with webhook. Don't forget to check the latest version of Webhook-Disco

It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help

[Magento 1 Extension] It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help (without any php code).

Comments
  • Fix actions/cache ::set-output deprecated

    Fix actions/cache ::set-output deprecated

    GitHub Actions log messages: "The set-output command is deprecated and will be disabled soon. Please upgrade to using Environment Files."

    • More info: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
    • And on the official actions/cache@3 documentation page where an example is given: https://github.com/actions/cache/blob/main/examples.md#php---composer

    And 3 weeks ago, an issue was posted on GitHub's actions/cache https://github.com/actions/cache/issues/1142 mentioning the warning from the GitHub Actions' logs.

    opened by pH-7 0
Releases(v1.0.2)
  • v1.0.2(Jun 9, 2023)

  • v1.0.1(Jun 9, 2023)

  • v1.0.0(Jun 9, 2023)

    The first stable version of the PHP HTTP Header Response πŸŽ‰

    How to use this new library

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

    Enjoy! πŸŽ‰

    Source code(tar.gz)
    Source code(zip)
Owner
β™š PH⑦ de Soriaβ„’β™›
βš‘οΈπ™€π™£π™©π™π™ͺπ™¨π™žπ™–π™¨π™©π™žπ™˜ & π™‹π™–π™¨π™¨π™žπ™€π™£π™–π™©π™š π˜Ώπ™šπ™« 🎈Everyday-Learning, Coding, Eating Healthy and Hiking are my FUEL! πŸš€ Enjoy 80/20 & Parkinson's Law πŸ€–
β™š PH⑦ de Soriaβ„’β™›
Adds a header to every response to try and twart Google's usage of your site in it's FLoC tracking method.

Laravel No FLoC This package will add the Permissions-Policy: interest-cohort=() to try and twart Google's usage of your site in it's FLoC tracking me

Jean-Philippe Murray 11 Jul 14, 2022
A SilverStripe module for conveniently injecting JSON-LD metadata into the header of each rendered page in SilverStripe

A SilverStripe module for conveniently injecting JSON-LD metadata into the header of each rendered page in Silver

null 4 Apr 20, 2022
EXT:server-timing adds Server-Timing Header with usefull information

EXT:server_timing - see your performance installation composer require kanti/server-timing at the moment there is nothing to configure Server timings

Matthias Vogel 4 Oct 26, 2022
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers

Magento 2 SMTP Extension - Gmail, G Suite, Amazon SES, Office 365, Mailgun, SendGrid, Mandrill and other SMTP servers. For Magento 2.0.x, 2.1.x, 2.2.x

MagePal :: Magento Extensions 303 Oct 7, 2022
Package to send customer specific prices to Magento from a Laravel application using a configurable source.

Laravel Magento Customer Prices This package provides a way to add customer specific prices to Magento from a Laravel app. By default, it uses the Mag

JustBetter 14 Nov 4, 2022
Package to send prices to Magento from a Laravel application using a configurable source.

Laravel Magento Prices Package to send prices to Magento from a Laravel application using a configurable source. Features The idea is that we want to

JustBetter 15 Nov 4, 2022
Simple loader to send request and read response from address.

Simple loader to send request and read response from address. Uses cURL extension. Composer package.

null 2 May 17, 2022
A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.

Laravel SES Tracking Setup the AWS infrastructure to handle email events using SES/SNS and http/s endpoints with a single Laravel artisan command. Thi

null 11 Apr 26, 2022
A simple HTTP server behaving as proxy between webhooks and Appwrite Functions.

A simple HTTP server behaving as proxy between webhooks and Appwrite Functions, allowing for instance Stripe payments integration into Appwrite.

Matej Bačo 21 Nov 30, 2022
An alternative to run cron jobs that uses simple HTTP requests

SilverStripe Simple Jobs An alternative to run cron jobs that uses simple HTTP requests. This module require SilverStripe CronTask. Why? Configuring c

Thomas Portelange 1 Jul 4, 2022