Skip to content

A simple OOP wrapper to work with HTTP headers in PHP

License

Notifications You must be signed in to change notification settings

http-php/headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Headers

Latest Version PHP Version Tests Total Downloads

This package is to allow you to create HTTP Headers in PHP, in a simple and reliable way.

Installation

composer require http-php/headers

Usage

To use this package, it is very simple. Create a header using the following code:

use HttpPHP\Headers\Header;

$header = Header::make(
    key: 'User-Agent',
    value: 'My-Awesome-Package',
);

$header->toHeader(); // ['User-Agent' => 'My-Awesome-Package'];

The package currently supports the following header value types:

  • String
  • Integer
  • Float
  • Boolean (although these will return 1 and 0)
  • Arrays (these will return json encoded strings)
  • Closures

It is important to note that if you pass a closure, that it must return something that can be cast to a string using strval.

Testing

To run the test suite:

composer run test

Credits

LICENSE

The MIT LIcense (MIT). Please see License File for more information.

About

A simple OOP wrapper to work with HTTP headers in PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages