Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ph-7/justhttpstatuscodes
The Simplest & Cleanest HTTP Status Codes for PHP. All PHP HTTP Status Codes are stored into beautiful constant names ๐จ Ideal when you develop an API that involves various HTTP codes ๐
https://github.com/ph-7/justhttpstatuscodes
clean-code http http-codes http-status-code php php-status-code status-code-constants status-codes
Last synced: 4 months ago
JSON representation
The Simplest & Cleanest HTTP Status Codes for PHP. All PHP HTTP Status Codes are stored into beautiful constant names ๐จ Ideal when you develop an API that involves various HTTP codes ๐
- Host: GitHub
- URL: https://github.com/ph-7/justhttpstatuscodes
- Owner: pH-7
- License: mit
- Created: 2021-10-09T02:44:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T09:26:38.000Z (4 months ago)
- Last Synced: 2024-10-23T07:27:59.838Z (4 months ago)
- Topics: clean-code, http, http-codes, http-status-code, php, php-status-code, status-code-constants, status-codes
- Language: PHP
- Homepage: https://packagist.org/packages/ph-7/just-http-status-codes
- Size: 393 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Just HTTP Status Codes
### Empowers your projects with elegant clean practices ๐ซ
- [๐ Overview](#-overview)
- [โ๏ธ PHP Requirement](#-php-requirement)
- [๐คฉ Usage](#-usage)
- [๐งโ๐ณ About](#-who-made-this)
- [๐บ Watch How I've Built It](#-building-this-library-together-)
- [โ๏ธ Who I Am](#-who-made-this)
- [โ๏ธ License](#%EF%B8%8F-license)## ๐ Overview
**Simplest. Clean. Efficient.** Just what your project needs ๐งน
[![Ko Fi - Offer Me A Coffee](media/kofi-logo.png)](https://ko-fi.com/phenry)
Don't hardcode HTTP status codes. Magic numbers (hard-coded numbers) make your code hard to read and understood.
When you have all status codes are stored in readable constants, it makes the development of your application so easy and enjoyable.
It prevents you from using the wrong HTTP status code and saves time and energy when developing an API that involves various HTTP status codes to be sent.
![PHP HTTP Status Codes constants](media/php-http-status-codes.png)
## ๐ PHP Requirement
[PHP v7.3](https://www.php.net/releases/7_3_0.php) or newer ๐
## ๐ Installation
```
composer require ph-7/just-http-status-codes
```If you don't already use composer in your project, include [Composer's autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading) as below in the main index file, bootstrap or in another file that is always included in all pages.
```php
require __DIR__ . '/vendor/autoload.php';
```## ๐ฅณ Usage
Just use the beautiful HTTP status code you need.
Like below ๐
```php
use PH7\JustHttp\StatusCode;StatusCode::OK; // This is 200
StatusCode::CREATED; // 201 code
StatusCode::NOT_FOUND; // 404
StatusCode::INTERNAL_SERVER_ERROR; // 500
```## ๐ช Building this library, together! ๐
[![Watch the video][video-thumbnail]](https://www.youtube.com/watch?v=fK9K-UrLHNE)
๐ **[Click here to watch on YouTube](https://www.youtube.com/watch?v=fK9K-UrLHNE)**
## ๐งโ๐ณ Who made this...?
[![Pierre-Henry Soria](https://s.gravatar.com/avatar/a210fe61253c43c869d71eaed0e90149?s=200)](https://ph7.me 'Pierre-Henry Soria personal website')
**[Pierre-Henry Soria](https://ph7.me)**, a highly passionate, zen & pragmatic software engineer ๐
๏ธโ๏ธ Are you enjoying it? **[Offer me a coffee](https://ko-fi.com/phenry)** (what's your favorite coffee? Mine is almond flat white ๐)
[![@phenrysay][twitter-icon]](https://x.com/phenrysay) [![pH-7][github-icon]](https://github.com/pH-7) [![YouTube Tech Videos][youtube-icon]](https://www.youtube.com/@pH7Programming "YouTube Tech Channel")
## โ๏ธ License
**Just HTTP StatusCodes** is generously distributed under the _[MIT](https://opensource.org/licenses/MIT)_ ๐ Enjoy!
[twitter-icon]: https://img.shields.io/badge/x-000000?style=for-the-badge&logo=x
[github-icon]: https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white
[youtube-icon]: https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white
[video-thumbnail]: https://i1.ytimg.com/vi/fK9K-UrLHNE/sddefault.jpg