PHPackages                             sinemacula/http-primitives-php - 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. sinemacula/http-primitives-php

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

sinemacula/http-primitives-php
==============================

Standalone, framework-agnostic PHP 8.3+ package providing typed backed enums for HTTP protocol primitives with zero runtime dependencies.

v2.0.1(2mo ago)038Apache-2.0PHPPHP ^8.3CI passing

Since Mar 13Pushed 2mo agoCompare

[ Source](https://github.com/sinemacula/http-primitives-php)[ Packagist](https://packagist.org/packages/sinemacula/http-primitives-php)[ RSS](/packages/sinemacula-http-primitives-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (5)Dependencies (25)Versions (8)Used By (0)

HTTP Primitives
===============

[](#http-primitives)

[![Latest Stable Version](https://camo.githubusercontent.com/a833fed6b37b0a0207b326d84ece7da2467db9990d7be4678f3b15a63c073b78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e656d6163756c612f687474702d7072696d6974697665732d7068702e737667)](https://packagist.org/packages/sinemacula/http-primitives-php)[![Build Status](https://github.com/sinemacula/http-primitives-php/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/sinemacula/http-primitives-php/actions/workflows/tests.yml)[![Maintainability](https://camo.githubusercontent.com/6f467dfe30b2a797ae0619f4783c164a8a212ea3cec18f9a4c7b1cce44fe90ff/68747470733a2f2f716c74792e73682f67682f73696e656d6163756c612f70726f6a656374732f687474702d7072696d6974697665732d7068702f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/sinemacula/projects/http-primitives-php)[![Code Coverage](https://camo.githubusercontent.com/d87a1832a6dc0a8f3ebf39dfe12cc495a97700a8cb61f32a46940eb455ee2194/68747470733a2f2f716c74792e73682f67682f73696e656d6163756c612f70726f6a656374732f687474702d7072696d6974697665732d7068702f636f7665726167652e737667)](https://qlty.sh/gh/sinemacula/projects/http-primitives-php)[![Total Downloads](https://camo.githubusercontent.com/14aeb642705b714294fa0bd4438076cc29d8ce3f7dbebb0a9a00ed2002c63c66/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696e656d6163756c612f687474702d7072696d6974697665732d7068702e737667)](https://packagist.org/packages/sinemacula/http-primitives-php)

Standalone, framework-agnostic PHP 8.3+ package providing typed backed enums for HTTP protocol primitives. Zero runtime dependencies.

Enums
-----

[](#enums)

EnumBacking TypeCasesDescription`HttpStatus``int`63All standard HTTP status codes (1xx-5xx)`HttpMethod``string`9HTTP request methods per RFC 9110`MediaType``string`43Common MIME types across 7 categories`HttpHeader``string`61Standard and non-standard HTTP headers`CacheDirective``string`16Cache-Control directive values`AuthScheme``string`3HTTP authentication schemes`Charset``string`20Common character encodingsAll enums live under the `SineMacula\Http\Enums` namespace.

Helper Methods
--------------

[](#helper-methods)

Each enum includes contextual helper methods:

- **HttpStatus** -- `getCode()`, `getStatusLine()`, `getReasonPhrase()`, `isInformational()`, `isSuccess()`, `isRedirection()`, `isClientError()`, `isServerError()`
- **HttpMethod** -- `getVerb()`, `isSafe()`, `isIdempotent()`
- **MediaType** -- `getMimeType()`, `withCharset()`, `getExtension()`, `isApplication()`, `isText()`, `isMultipart()`, `isImage()`, `isAudio()`, `isVideo()`, `isFont()`
- **HttpHeader** -- `getName()`, `isStandard()`
- **CacheDirective** -- `isRequestDirective()`, `isResponseDirective()`
- **Charset** -- `getEncoding()`

Installation
------------

[](#installation)

```
composer require sinemacula/http-primitives-php
```

Usage
-----

[](#usage)

```
use SineMacula\Http\Enums\Charset;
use SineMacula\Http\Enums\HttpStatus;
use SineMacula\Http\Enums\HttpMethod;
use SineMacula\Http\Enums\MediaType;

// Status code helpers
$status = HttpStatus::from(404);
$status->getCode();          // 404
$status->getStatusLine();    // '404 Not Found'
$status->isClientError();    // true
$status->getReasonPhrase();  // 'Not Found'

// Method safety checks
HttpMethod::GET->isSafe();        // true
HttpMethod::POST->isIdempotent(); // false

// Media type inspection
MediaType::APPLICATION_JSON->isApplication(); // true
MediaType::APPLICATION_JSON->getExtension();  // 'json'

// Content type composition
MediaType::TEXT_CSV->withCharset(Charset::UTF_8); // 'text/csv; charset=utf-8'
```

Testing
-------

[](#testing)

```
composer test
composer test-coverage
composer check
```

Contributing
------------

[](#contributing)

Contributions are welcome via GitHub pull requests.

Security
--------

[](#security)

If you discover a security issue, please contact Sine Macula directly rather than opening a public issue.

License
-------

[](#license)

Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance85

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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 ~6 days

Total

5

Last Release

79d ago

Major Versions

v1.0.2 → v2.0.02026-03-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/6262ea965c244b0c946a2f29a94da05e30846c066a0b59399466216654c78fe6?d=identicon)[sinemacula](/maintainers/sinemacula)

---

Top Contributors

[![sinemacula-ben](https://avatars.githubusercontent.com/u/118753672?v=4)](https://github.com/sinemacula-ben "sinemacula-ben (8 commits)")

---

Tags

httpphpstatus codesenumssine macula

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sinemacula-http-primitives-php/health.svg)

```
[![Health](https://phpackages.com/badges/sinemacula-http-primitives-php/health.svg)](https://phpackages.com/packages/sinemacula-http-primitives-php)
```

###  Alternatives

[hannesvdvreken/guzzle-debugbar

A Guzzle middleware that logs requests to debugbar's timeline

76423.5k2](/packages/hannesvdvreken-guzzle-debugbar)[swoole-bundle/swoole-bundle

Open/Swoole Symfony Bundle

7358.5k](/packages/swoole-bundle-swoole-bundle)

PHPackages © 2026

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