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