bogosoft / serialization
Serialization-related contracts and implementations for PHP.
1.0.0
2019-12-24 04:16 UTC
Requires
- php: >=7.1
- ext-json: *
- bogosoft/core: ^2
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.6
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2025-03-24 16:25:38 UTC
README
A library of contracts and simple implementations for serializing and deserializing data.
Requirements
- PHP 7.1+
Installation
composer install bogosoft/serialization
Interfaces
Interface Name | Description |
---|---|
IDeserializer |
A strategy for deserializing data from an input stream. |
ISerializer |
A strategy for serializing data to an output stream. |
Implementations
Implementation Name | Description |
---|---|
JsonSerializer |
A JSON serializer/deserializer. |
PhpSerializer |
A serializer/deserializer implementation that relies on PHP's serialize and unserialize functions. |
Example Usage
$serializer = new \Bogosoft\Serialization\PhpSerializer(); $expected = 'Hello, World!'; $handle = fopen('php://memory', 'r+b'); $serialization = $serializer->serialize($handle, $expected); fseek($handle, 0); $actual = $serializer->deserialize($handle); var_dump($actual === $expected); # outputs: bool(true)