https://github.com/rayanlevert/http
PHP enumerations for HTTP codes and methods
https://github.com/rayanlevert/http
enumeration http-code http-method php
Last synced: about 1 month ago
JSON representation
PHP enumerations for HTTP codes and methods
- Host: GitHub
- URL: https://github.com/rayanlevert/http
- Owner: rayanlevert
- License: bsd-3-clause
- Created: 2023-12-06T07:51:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T20:24:12.000Z (over 1 year ago)
- Last Synced: 2025-10-13T04:12:44.891Z (4 months ago)
- Topics: enumeration, http-code, http-method, php
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Simple functionalites handling HTTP (codes and methods) via PHP enumerations (from 8.1)
[](https://packagist.org/packages/rayanlevert/http)
[](https://packagist.org/packages/rayanlevert/http)
[](https://codecov.io/gh/rayanlevert/http)
> Refer to php-fig https://github.com/php-fig/http-message-util
### RayanLevert\Http\Codes
PHP enumeration with HTTP codes [RayanLevert\Http\Codes](src/Codes.php)
### DisDev\Http\Methods
PHP enumeration with HTTP methods
```php
enum Methods: string
{
case HEAD = 'HEAD';
case GET = 'GET';
case POST = 'POST';
case PUT = 'PUT';
case PATCH = 'PATCH';
case DELETE = 'DELETE';
case PURGE = 'PURGE';
case OPTIONS = 'OPTIONS';
case TRACE = 'TRACE';
case CONNECT = 'CONNECT';
}
\RayanLevert\Http\Methods::HEAD // 'HEAD'
```
### RayanLevert\Http\Exception
PHP exception initialized with an HTTP code with `RayanLevert\Http\Codes`
```php
// HTTP 401 error
$oException = new \RayanLevert\Http\Exception('Unauthorized', \RayanLevert\Http\Codes::CLIENT_UNAUTHORIZED)
```