{"id":13828538,"url":"https://github.com/thunderer/Serializard","last_synced_at":"2025-07-09T06:32:04.364Z","repository":{"id":55008486,"uuid":"47219306","full_name":"thunderer/Serializard","owner":"thunderer","description":"Flexible serializer encouraging good object design","archived":false,"fork":false,"pushed_at":"2021-01-15T17:54:10.000Z","size":80,"stargazers_count":28,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T19:04:14.643Z","etag":null,"topics":["array","hydration","hydrator","json","normalizer","parser","php","serialization","serializer","xml","yaml"],"latest_commit_sha":null,"homepage":"http://kowalczyk.cc","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thunderer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-01T21:44:28.000Z","updated_at":"2025-02-06T14:10:09.000Z","dependencies_parsed_at":"2022-08-14T09:00:23.951Z","dependency_job_id":null,"html_url":"https://github.com/thunderer/Serializard","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/thunderer/Serializard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderer%2FSerializard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderer%2FSerializard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderer%2FSerializard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderer%2FSerializard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thunderer","download_url":"https://codeload.github.com/thunderer/Serializard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunderer%2FSerializard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261984400,"owners_count":23240281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","hydration","hydrator","json","normalizer","parser","php","serialization","serializer","xml","yaml"],"created_at":"2024-08-04T09:02:51.233Z","updated_at":"2025-07-09T06:32:04.121Z","avatar_url":"https://github.com/thunderer.png","language":"PHP","readme":"# Serializard\n\n[![Build Status](https://travis-ci.org/thunderer/Serializard.svg?branch=master)](https://travis-ci.org/thunderer/Serializard)\n[![Latest Stable Version](https://poser.pugx.org/thunderer/serializard/v/stable)](https://packagist.org/packages/thunderer/serializard)\n[![License](https://poser.pugx.org/thunderer/serializard/license)](https://packagist.org/packages/thunderer/serializard)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thunderer/Serializard/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/thunderer/Serializard/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/thunderer/Serializard/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/thunderer/Serializard/?branch=master)\n[![Dependency Status](https://www.versioneye.com/user/projects/56bb2af62a29ed0034380546/badge.svg)](https://www.versioneye.com/user/projects/56bb2af62a29ed0034380546)\n\nSerializard is a library for (un)serialization of data of any complexity. Its main focus is to give user as much flexibility as possible by delegating the (un)serialization logic to the programmer to encourage good object design and only supervising the process hiding the unpleasant details about it.\n\n# Installation\n\nThis library is available on Composer/Packagist as `thunderer/serializard`.\n\n# Usage\n\nLet's consider a simple User class with two properties and some setup code:\n\n```php\nfinal class User\n{\n    private $id;\n    private $name;\n\n    public function __construct(int $id, string $name) { /* ... */ }\n\n    public function getId() { return $this-\u003eid; }\n    public function getName() { return $this-\u003ename; }\n}\n\n$user = new User(1, 'Thomas');\n\n$formats = new FormatContainer();\n$formats-\u003eadd('json', new JsonFormat());\n\n$hydrators = new FallbackHydratorContainer();\n$normalizers = new FallbackNormalizerContainer();\n$serializard = new Serializard($formats, $normalizers, $hydrators);\n```\n\n## Serialization\n\nSerialization is controlled by registering handlers used in normalization phase:\n\n```php\n$normalizers-\u003eadd(User::class, function(User $user) {\n    return [\n        'id' =\u003e $user-\u003egetId(),\n        'name' =\u003e $user-\u003egetName(),\n    ];\n});\n\n$result = $serializard-\u003eserialize($user, 'json');\n// result is {\"id\":1,\"name\":\"Thomas\"}\n```\n\n## Unserialization\n\nUnserialization can be controlled by registering callables able to reconstruct objects from data parsed from input text:\n\n```php\n$hydrators-\u003eadd(User::class, function(array $data) {\n    return new User($data['id'], $data['name']);\n});\n\n$json = '{\"id\":1,\"name\":\"Thomas\"}';\n$user = $serializard-\u003eunserialize($json, User::class, 'json');\n```\n\n# Formats\n\n- **JSON** in `JsonFormat` converts objects to JSON,\n- **Array** in `ArrayFormat` just returns object graph normalized to arrays of scalars,\n- **YAML** in `YamlFormat` converts objects to YAML (uses `symfony/yaml`),\n- **XML** in `XmlFormat` converts objects to XML (uses `ext-dom`).\n\n# License\n\nSee LICENSE file in the main directory of this library.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthunderer%2FSerializard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthunderer%2FSerializard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthunderer%2FSerializard/lists"}