amphp/serialization

Serialization tools for IPC and data storage in PHP.

Fund package maintenance!
amphp

Installs: 20 395 770

Dependents: 18

Suggesters: 0

Security: 0

Stars: 110

Watchers: 10

Forks: 3

Open Issues: 1

v1.0.0 2020-03-25 21:39 UTC

This package is auto-updated.

Last update: 2024-10-29 22:39:19 UTC


README

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. amphp/serialization is a library providing serialization tools for IPC and data storage in PHP.

Latest Release MIT License

Installation

This package can be installed as a Composer dependency.

composer require amphp/serialization

Serializer

The main interface of this library is Amp\Serialization\Serializer.

<?php

namespace Amp\Serialization;

interface Serializer
{
    /**
     * @param mixed $data
     *
     * @throws SerializationException
     */
    public function serialize($data): string;

    /**
     * @return mixed
     *
     * @throws SerializationException
     */
    public function unserialize(string $data);
}

JSON

JSON serialization can be used with the JsonSerializer.

Native Serialization

Native serialization (serialize / unserialize) can be used with the NativeSerializer.

Passthrough Serialization

Sometimes you already have a string and don't want to apply additional serialization. In these cases, you can use the PassthroughSerializer.

Compression

Often, serialized data can be compressed quite well. If you don't need interoperability with other systems deserializing the data, you can compress your serialized payloads by wrapping your Serializer instance in an CompressingSerializer.

Security

If you discover any security related issues, please email me@kelunik.com instead of using the issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.