2017 © Pedro Peláez
 

library serial

Consistent serialization helpers for multiple backends

image

duncan3dc/serial

Consistent serialization helpers for multiple backends

  • Tuesday, May 29, 2018
  • by duncan3dc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 104,747 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 14 Versions
  • 5 % Grown

The README.md

serial

A collection of PHP serialization helpers with a consistent interface for each., (*1)

release build](https://github.com/duncan3dc/serial/actions?query=branch%3Amaster+workflow%3Abuildcheck) coverage, (*2)

Available Classes

  • Json (using the native json_* functions)
  • Yaml (using the Symfony Yaml component)
  • Php (using the native serialize/unserialize functions)

Interface

All serialization classes implement the interface duncan3dc\Serial\SerialInterface, (*3)

Examples

Convert array data to string format, (*4)

use duncan3dc\Serial\Json;
$data = BusinessLogic::getDataAsArray();
$json = Json::encode($data);

Convert string formatted data to an array, (*5)

use duncan3dc\Serial\Yaml;
$yaml = Api::getYamlResponse($request);
$response = Yaml::decode($yaml);

Convient methods to serialize and store data on disk, (*6)

use duncan3dc\Serial\Json;
$filename = "/tmp/file.json";
$data = BusinessLogic::getDataAsArray();
Json::encodeToFile($filename, $data);

Retrieve previously stored data from disk, (*7)

use duncan3dc\Serial\Json;
$filename = "/tmp/file.json";
$data = Json::decodeFromFile($filename);

ArrayObject

The decode() and decodeFromFile() methods return a custom ArrayObject., (*8)

If you need a plain array you can get one like so:, (*9)

$array = Json::decode($jsonString)->asArray();

There are also helper methods to convert to any of the available serialization formats., (*10)

$data = Json::decode($jsonString);
$yaml = $data->asYaml();
$json = $data->asJson();
$php = $data->asPhp();

The Versions

29/05 2018

dev-master

9999999-dev https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

19/04 2018

dev-no-more-scalars

dev-no-more-scalars https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

19/04 2018

dev-performance

dev-performance https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

19/04 2018

dev-ini

dev-ini https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

19/04 2018

dev-toml

dev-toml https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

19/04 2018

dev-serializer-instances

dev-serializer-instances https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

09/04 2018

1.1.0

1.1.0.0 https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

02/01 2018

dev-xml

dev-xml https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

02/01 2018

1.1.x-dev

1.1.9999999.9999999-dev https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

18/08 2016

1.0.0

1.0.0.0 https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json serialization serializer yaml serialisation serialiser

07/02 2015

0.4.0

0.4.0.0 https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

json serialization serializer yaml serialisation serialiser

13/10 2014

0.3.0

0.3.0.0 https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

json serialization serializer yaml serialisation serialiser

13/10 2014

0.2.0

0.2.0.0 https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

json serialization serializer yaml serialisation serialiser

13/10 2014

0.1.0

0.1.0.0 https://github.com/duncan3dc/serial

Consistent serialization helpers for multiple backends

  Sources   Download

Apache-2.0

The Requires

 

json serialization serializer serialisation serialiser