HttpData
HttpData is a simple package for encoding and decoding data to be sent via http requests., (*1)
Installation
Composer
From the command line, run:, (*2)
composer require datrim/http-data
Usage
The Basics
With the package now installed, you may use the two classes like so:, (*3)
Encoding data (compressed)
<?php
use Datrim\HttpData\HttpDataEncoder;
$data = [
'name' => 'MyData',
'value' => 'My data value'
];
To encode data compressed (default), (*4)
$encoder = new HttpDataEncoder($data);
or, if the data should be transmitted uncompressed., (*5)
$encoder = new HttpDataEncoder($data, false);
Then to get the encoded data:, (*6)
$encoded Data = $encoder->data();
Decoding data
<?php
use Datrim\HttpData\HttpDataDecoder;
$decoder = new HttpDataDecoder($encodedData);
$decodedData = $decoder->data();
That's it!, (*7)
License
The HttpData package is open-sourced software licensed under the MIT license, (*8)