library http
Hypertext Transfer Protocol (HTTP) utilities for PHP
delight-im/http
Hypertext Transfer Protocol (HTTP) utilities for PHP
- Wednesday, January 24, 2018
- by delight-im
- Repository
- 5 Watchers
- 6 Stars
- 33,976 Installations
- PHP
- 2 Dependents
- 0 Suggesters
- 1 Forks
- 0 Open issues
- 4 Versions
- 23 % Grown
PHP-HTTP
Hypertext Transfer Protocol (HTTP) utilities for PHP, (*1)
Requirements
Installation
-
Include the library via Composer [?]:, (*2)
$ composer require delight-im/http
-
Include the Composer autoloader:, (*3)
require __DIR__ . '/vendor/autoload.php';
Usage
-
Retrieving a header (with optional value prefix), (*4)
$header = \Delight\Http\ResponseHeader::get('Content-Type');
// or
$header = \Delight\Http\ResponseHeader::get('Content-Type', 'text/');
-
Setting a header (overwriting other headers with the same name), (*5)
\Delight\Http\ResponseHeader::set('X-Frame-Options', 'sameorigin');
-
Adding a header (preserving other headers with the same name), (*6)
\Delight\Http\ResponseHeader::add('Vary', 'User-Agent');
-
Removing a header (with optional value prefix), (*7)
$success = \Delight\Http\ResponseHeader::remove('X-Powered-By');
// or
$success = \Delight\Http\ResponseHeader::remove('X-Powered-By', 'PHP');
-
Retrieving and removing a header at once (with optional value prefix), (*8)
$header = \Delight\Http\ResponseHeader::take('Set-Cookie');
// or
$header = \Delight\Http\ResponseHeader::take('Set-Cookie', 'mysession=');
Contributing
All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed., (*9)
License
This project is licensed under the terms of the MIT License., (*10)