datrim/http-data

Http data compression and serialization

1.0.1 2020-05-03 19:29 UTC

This package is auto-updated.

Last update: 2024-03-29 03:01:32 UTC


README

HttpData is a simple package for encoding and decoding data to be sent via http requests.

Installation

Composer

From the command line, run:

composer require datrim/http-data

Usage

The Basics

With the package now installed, you may use the two classes like so:

Encoding data (compressed)

<?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();

Decoding data

<?php

use Datrim\HttpData\HttpDataDecoder;

$decoder = new HttpDataDecoder($encodedData);
$decodedData = $decoder->data();

That's it!

License

The HttpData package is open-sourced software licensed under the MIT license