定制 ph-7/php-http-response-header 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ph-7/php-http-response-header

最新稳定版本:v1.0.4

Composer 安装命令:

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

包简介

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

README 文档

README

Simple PHP package to safely 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 (my favorite coffee to start the day is almond flat white 😋)

@phenrysay YouTube Tech Videos pH-7

🎥 Me building this package

Watch the video

👉 Click here to watch on YouTube, me building this package from A to Z.

PHP HTTP Response Headers - Send Header By HTTP Code

⚖️ License

PHP HTTP Response is generously distributed under the MIT 🎉 Enjoy!

统计信息

  • 总下载量: 237
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-09