Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nabeghe/headers-reader-php
A simple way to read headers from the `getallheaders` function in PHP.
https://github.com/nabeghe/headers-reader-php
header headers php php-headers php-helper php-helpers php-libraries php-library
Last synced: 9 days ago
JSON representation
A simple way to read headers from the `getallheaders` function in PHP.
- Host: GitHub
- URL: https://github.com/nabeghe/headers-reader-php
- Owner: nabeghe
- License: mit
- Created: 2024-10-22T18:02:38.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-12-19T17:16:40.000Z (15 days ago)
- Last Synced: 2024-12-19T18:26:59.095Z (15 days ago)
- Topics: header, headers, php, php-headers, php-helper, php-helpers, php-libraries, php-library
- Language: PHP
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Headers Reader for PHP
> A simple way to read headers from the `getallheaders` function in PHP.
## 🫡 Usage
### 🚀 Installation
You can install the package via composer:
```bash
composer require nabeghe/headers-reader
```
### Example 1 - Main Class
```php
use Nabeghe\HeadersReader\Headers;echo 'X-Custom-1: '.Headers::get('X-Custom-1', 'The default value for X-Custom-1')."\n
";
echo 'X-Custom-2: '.Headers::get('X-Custom-2', 'The default value for X-Custom-2')."\n
";
echo 'X-Custom-3: '.Headers::get('X-Custom-3', 'The default value for X-Custom-3')."\n
";
echo 'X-Custom-4: '.Headers::get('X-Custom-4', 'The default value for X-Custom-4')."\n
";
echo 'X-Custom-5: '.Headers::get('X-Custom-4')."\n
"; // Default value is blank.print_r(Headers::all()); // Returns all headers.
Headers::flush(); // Clears the cache.
```### Example 1 - Custom Class
```php
use Nabeghe\HeadersReader\Headers;class MyHeaders extends Headers
{
public const DEFAULT = 'The general default value';public const DEFAULTS = [
'X-Custom-1' => 'The default value for X-Custom-1',
'X-Custom-2' => 'The default value for X-Custom-2',
'X-Custom-3' => 'The default value for X-Custom-3',
'X-Custom-4' => 'The default value for X-Custom-4',
];
}echo 'X-Custom-1: '.MyHeaders::get('X-Custom-1')."\n
";
echo 'X-Custom-2: '.MyHeaders::get('X-Custom-2')."\n
";
echo 'X-Custom-3: '.MyHeaders::get('X-Custom-3')."\n
";
echo 'X-Custom-4: '.MyHeaders::get('X-Custom-4')."\n
";
echo 'X-Custom-5: '.MyHeaders::get('X-Custom-5')."\n
";
```
## 📖 License
Copyright (c) Hadi Akbarzadeh
Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.