https://github.com/swoft-cloud/swoft-serialize
Data serializer for PHP
https://github.com/swoft-cloud/swoft-serialize
php-library serialization swoft-component
Last synced: 10 months ago
JSON representation
Data serializer for PHP
- Host: GitHub
- URL: https://github.com/swoft-cloud/swoft-serialize
- Owner: swoft-cloud
- License: apache-2.0
- Created: 2019-11-11T15:14:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-17T03:25:12.000Z (over 6 years ago)
- Last Synced: 2025-08-05T00:22:14.332Z (10 months ago)
- Topics: php-library, serialization, swoft-component
- Language: PHP
- Size: 30.3 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Data Serialize
[](https://packagist.org/packages/swoft/serialize)
[](https://secure.php.net/)
[](https://github.com/swoft-cloud/swoft-serialize/blob/master/LICENSE)
[](https://github.com/swoft-cloud/swoft-serialize/actions)
Universal data serializer for PHP
Serializers:
- json(by `json_encode`)
- php(by `serialize`)
- igbinary(by extension `igbinary`)
- msgpack(by extension `msgpack`)
## Install
- composer command
```bash
composer require swoft/serialize
```
## Usage
```php
$serializer = new JsonSerializer();
// $serializer = new PhpSerializer();
// $serializer = new IgBinarySerializer();
// $serializer = new MsgPackSerializer();
// serialize data
$string = $serializer->serialize($data);
// unserialize string
$data = $serializer->unserialize($string);
```
## Unit testing
```bash
phpunit
```
## LICENSE
The Component is open-sourced software licensed under the [Apache license](LICENSE).