koriym/http-constants

HTTP协议常量

1.2.1 2021-10-12 11:00 UTC

This package is auto-updated.

Last update: 2024-09-12 16:59:56 UTC


README

包含HTTP协议的状态码、请求方法和头部的值。仅常量。

示例

use Koriym\HttpConstants\HttpStatusCode;
use Koriym\HttpConstants\RequestHeader;
use Koriym\HttpConstants\ResponseHeader;
use Koriym\HttpConstants\MediaType;
use Koriym\HttpConstants\Method;

http_response_code(StatusCode::BAD_REQUEST);
header(ResponseHeader::CONTENT_TYPE . ': ' . MediaType::APPLICATION_JSON_API);
// Content-Type: application/vnd.api+json
header(ResponseHeader::CACHE_CONTROL . ': max-age=3600');
// Cache-Control: max-age=3600

安装

$ composer require koriym/http-constants

另见 PSR Http Message Util