http-php / messages
A simple OOP wrapper to work with HTTP messages in PHP
dev-main
2023-02-06 12:02 UTC
Requires
- php: ^8.2
- http-php/headers: dev-main
- http-php/payload: dev-main
Requires (Dev)
- laravel/pint: ^1.4.1
- pestphp/pest: ^1.22.4
- phpstan/phpstan: ^1.9.14
This package is auto-updated.
Last update: 2024-11-06 15:40:52 UTC
README
This package is to allow you to create HTTP Messages in PHP, in a simple and reliable way.
Installation
composer require http-php/message
Usage
To use this package, it is very simple. Create a message using the following code:
use HttpPHP\Message\Message; $message = Message::make( payload: ['test' => 'payload'], ); // Add a header $message->withHeader( key: 'Authorization', value: 'Bearer some-super-secret-token', ); // Fetch the header value $message->header( key: 'Authorization', )->toString(); // 'Bearer some-super-secret-token' // Fetch all headers $message->headers(); // Fetch the payload $message->payload()->parse(); // Returns an array representation of the payload. $message->payload()->body(); // Returns the raw payload you wish to send.
Testing
To run the test suite:
composer run test
Credits
LICENSE
The MIT LIcense (MIT). Please see License File for more information.