akashjoshi1999/http-status-code

HTTP status code constants and helpers for PHP (Composer package)

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/akashjoshi1999/http-status-code

v1.0 2025-12-25 06:01 UTC

This package is auto-updated.

Last update: 2025-12-25 06:09:44 UTC


README

This lightweight PHP package provides named constants and helper methods for HTTP status codes so developers can use meaningful constant names instead of raw integers.

Installation

Add to your project using Composer (once published):

composer require akashjoshi1999/http-status-code

Or include locally via composer.json PSR-4 autoload.

Usage

use HttpStatusCode\HttpStatus;

// Use named constant instead of literal number
$status = HttpStatus::OK; // 200

// Get reason phrase
$phrase = HttpStatus::reasonPhrase($status); // 'OK'

// Get constant name from code
$name = HttpStatus::constantName(404); // 'NOT_FOUND'

// List all codes
$all = HttpStatus::all();

Files

  • src/HttpStatus.php — constants and helpers
  • examples/example.php — small usage example

Contributing

Contributions welcome. Add more codes or helper utilities as needed.

Running tests

Run the project's tests locally (after cloning/installing dependencies):

composer install
composer test
# or directly with PHPUnit:
php vendor/bin/phpunit --configuration phpunit.xml

Expected output (example):

OK (4 tests, 12 assertions)