PHPackages                             koriym/http-constants - 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. koriym/http-constants

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

koriym/http-constants
=====================

Constants for the HTTP protocol

1.2.1(4y ago)8752.0k↓15.5%112MITPHPPHP &gt;=7.1.0

Since Aug 30Pushed 6mo ago3 watchersCompare

[ Source](https://github.com/koriym/Koriym.HttpConstants)[ Packagist](https://packagist.org/packages/koriym/http-constants)[ RSS](/packages/koriym-http-constants/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (14)Used By (12)

Koriym.HttpConstants
====================

[](#koriymhttpconstants)

Provides frequently-used HTTP protocol constants for PHP applications. This library includes commonly-used status codes, request methods, headers, media types, and cache control directives that are typically referenced in PHP application code.

Example
-------

[](#example)

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

### Install

[](#install)

```
$ composer require koriym/http-constants

```

Scope and Philosophy
--------------------

[](#scope-and-philosophy)

This library focuses on **HTTP constants frequently used in PHP application code**, rather than providing comprehensive coverage of all HTTP specifications.

For example:

- CORS headers are included because they are commonly set in API endpoints
- Rate limiting status codes (429) are included for API development
- Security headers typically configured at the web server level are not included
- Basic image media types (image/png, etc.) are not included as they are rarely referenced in application code

HTTP Constants Coverage
-----------------------

[](#http-constants-coverage)

The following tables show commonly-used HTTP constants and whether they are included in this library (✓) or not (✗).

### HTTP Status Codes

[](#http-status-codes)

CodeNameIncludedReason if excluded100Continue✓101Switching Protocols✓102Processing✓103Early Hints✗Rarely used in PHP code200OK✓201Created✓202Accepted✓203Non-Authoritative Information✓204No Content✓205Reset Content✓206Partial Content✓207Multi-Status✗WebDAV-specific208Already Reported✗WebDAV-specific226IM Used✗Rarely used300Multiple Choices✓301Moved Permanently✓302Found✓303See Other✓304Not Modified✓305Use Proxy✓307Temporary Redirect✓308Permanent Redirect✓400Bad Request✓401Unauthorized✓402Payment Required✓403Forbidden✓404Not Found✓405Method Not Allowed✓406Not Acceptable✓407Proxy Authentication Required✓408Request Timeout✓409Conflict✓410Gone✓411Length Required✓412Precondition Failed✓413Request Entity Too Large✓414Request-URI Too Long✓415Unsupported Media Type✓416Requested Range Not Satisfiable✓417Expectation Failed✓418I'm a teapot✓421Misdirected Request✗HTTP/2 specific, rarely used422Unprocessable Entity✗In statusText only423Locked✗WebDAV-specific424Failed Dependency✗WebDAV-specific425Too Early✗Rarely used426Upgrade Required✗Rarely used in PHP code428Precondition Required✓429Too Many Requests✓431Request Header Fields Too Large✓451Unavailable For Legal Reasons✗Rarely used in PHP code500Internal Server Error✓501Not Implemented✓502Bad Gateway✓503Service Unavailable✓504Gateway Timeout✓505HTTP Version Not Supported✓506Variant Also Negotiates✗Rarely used507Insufficient Storage✗WebDAV-specific508Loop Detected✗WebDAV-specific510Not Extended✗Rarely used511Network Authentication Required✗Captive portal specific**IANA Registry**: [HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)

### HTTP Methods

[](#http-methods)

MethodIncludedReason if excludedGET✓POST✓PUT✓DELETE✓HEAD✓OPTIONS✓PATCH✓CONNECT✓TRACE✓LINK✓UNLINK✓PROPFIND✗WebDAV-specificPROPPATCH✗WebDAV-specificMKCOL✗WebDAV-specificCOPY✗WebDAV-specificMOVE✗WebDAV-specificLOCK✗WebDAV-specificUNLOCK✗WebDAV-specific**IANA Registry**: [HTTP Method Registry](https://www.iana.org/assignments/http-methods/http-methods.xhtml)

### HTTP Request Headers

[](#http-request-headers)

HeaderIncludedReason if excludedAccept✓Accept-Charset✓Accept-Datetime✓Accept-Encoding✓Accept-Language✓Access-Control-Request-Headers✓Access-Control-Request-Method✓Authorization✓Cache-Control✓Connection✓Content-Encoding✓Content-Length✓Content-MD5✓Content-Range✓Content-Type✓Cookie✓Date✓DNT✓Expect✓Forwarded✗Less common than X-Forwarded-\*From✓Front-End-Https✓Host✓If-Match✓If-Modified-Since✓If-None-Match✓If-Range✓If-Unmodified-Since✓Max-Forwards✓Origin✓Pragma✓Proxy-Authorization✓Proxy-Connection✓Range✓Referer✓Sec-Fetch-Dest✗Browser-set, not in PHP codeSec-Fetch-Mode✗Browser-set, not in PHP codeSec-Fetch-Site✗Browser-set, not in PHP codeTE✓Upgrade✓Upgrade-Insecure-Requests✗Browser-set, not in PHP codeUser-Agent✓Via✓Warning✓X-Csrf-Token✓X-Forwarded-For✓X-Forwarded-Proto✓X-Http-Method-Override✓X-Requested-With✓X-Wap-Profile✓**IANA Registry**: [Message Headers Registry](https://www.iana.org/assignments/message-headers/message-headers.xhtml)

### HTTP Response Headers

[](#http-response-headers)

HeaderIncludedReason if excludedAccept-Patch✓Accept-Ranges✓Access-Control-Allow-Credentials✓Access-Control-Allow-Headers✓Access-Control-Allow-Methods✓Access-Control-Allow-Origin✓Access-Control-Expose-Headers✓Access-Control-Max-Age✓Age✓Allow✓Cache-Control✓Connection✓Content-Disposition✓Content-Encoding✓Content-Language✓Content-Length✓Content-Location✓Content-MD5✓Content-Range✓Content-Security-Policy✓Content-Type✓Cross-Origin-Embedder-Policy✗Usually set in web server configCross-Origin-Opener-Policy✗Usually set in web server configCross-Origin-Resource-Policy✗Usually set in web server configDate✓ETag✓Expires✓Last-Modified✓Location✓P3P✓Permissions-Policy✗Usually set in web server configProxy-Authenticate✓Public-Key-Pins✓Referrer-Policy✗Usually set in web server configRefresh✓Retry-After✓Server✓Set-Cookie✓Status✓Strict-Transport-Security✓Trailer✓Transfer-Encoding✓Upgrade✓Vary✓Warning✓WWW-Authenticate✓X-Content-Duration✓X-Content-Type-Options✓X-Frame-Options✗Usually set in web server configX-Powered-By✓X-UA-Compatible✓X-XSS-Protection✓**IANA Registry**: [Message Headers Registry](https://www.iana.org/assignments/message-headers/message-headers.xhtml)

### Media Types

[](#media-types)

Media TypeIncludedReason if excluded*/*✓application/atom+xml✓application/graphql+json✗Could be added if requestedapplication/gzip✗Rarely referenced in PHP codeapplication/hal+json✓application/json✓application/ld+json✓application/octet-stream✓application/pdf✗Rarely referenced in PHP codeapplication/problem+json✗Could be added if requestedapplication/rdf+xml✓application/svg+xml✓application/vnd.api+json✓application/vnd.collection+json✓application/vnd.siren+json✓application/vnd.uber+json✓application/x-www-form-urlencoded✓application/xhtml+xml✓application/xml✓application/zip✗Rarely referenced in PHP codeimage/gif✗Rarely referenced in PHP codeimage/jpeg✗Rarely referenced in PHP codeimage/png✗Rarely referenced in PHP codeimage/svg+xml✗Rarely referenced in PHP codeimage/webp✗Rarely referenced in PHP codemultipart/form-data✓text/css✗Rarely referenced in PHP codetext/csv✗Rarely referenced in PHP codetext/html✓text/javascript✗Rarely referenced in PHP codetext/plain✓text/xml✓**IANA Registry**: [Media Types Registry](https://www.iana.org/assignments/media-types/media-types.xhtml)

### Cache-Control Directives

[](#cache-control-directives)

DirectiveIncludedReason if excludedpublic✓private✓no-cache✓no-store✓max-age✓s-maxage✓must-revalidate✓proxy-revalidate✓immutable✓stale-while-revalidate✓stale-if-error✓no-transform✗Less commonly usedonly-if-cached✗Client directive, less commonmax-stale✗Client directive, less commonmin-fresh✗Client directive, less common**RFC 9111**: [HTTP Caching](https://www.rfc-editor.org/rfc/rfc9111.html)

Related Projects
----------------

[](#related-projects)

See also [PSR Http Message Util](https://github.com/php-fig/http-message-util).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance47

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 93.1% 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 ~248 days

Recently: every ~376 days

Total

10

Last Release

1680d ago

Major Versions

0.1.0 → 1.0.02017-02-23

PHP version history (2 changes)0.1.0PHP &gt;=5.3.0

1.2.0PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/db4fc75ffc631168d0d7143b6f2c24b1534dfb921212bd851c026c5cbbb1344d?d=identicon)[koriym](/maintainers/koriym)

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (27 commits)")[![satoshi-ohshige](https://avatars.githubusercontent.com/u/20769904?v=4)](https://github.com/satoshi-ohshige "satoshi-ohshige (1 commits)")[![sylfabre](https://avatars.githubusercontent.com/u/3177556?v=4)](https://github.com/sylfabre "sylfabre (1 commits)")

---

Tags

http-codehttpconsntats

### Embed Badge

![Health badge](/badges/koriym-http-constants/health.svg)

```
[![Health](https://phpackages.com/badges/koriym-http-constants/health.svg)](https://phpackages.com/packages/koriym-http-constants)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

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

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

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

1.9k692.9M1.9k](/packages/psr-http-factory)[php-http/httplug

HTTPlug, the HTTP client abstraction for PHP

2.6k307.6M679](/packages/php-http-httplug)[psr/http-client

Common interface for HTTP clients

1.7k680.7M2.1k](/packages/psr-http-client)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)

PHPackages © 2026

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