{"id":21072898,"url":"https://github.com/h4kuna/serialize-polyfill","last_synced_at":"2025-05-16T06:30:50.245Z","repository":{"id":62513837,"uuid":"145829997","full_name":"h4kuna/serialize-polyfill","owner":"h4kuna","description":"Provide methods for serialization and use igbinary if is available.","archived":false,"fork":false,"pushed_at":"2024-07-31T10:10:36.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T21:51:32.785Z","etag":null,"topics":["igbinary","php","serialize"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/h4kuna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-23T09:15:24.000Z","updated_at":"2024-07-31T10:10:24.000Z","dependencies_parsed_at":"2024-07-28T10:47:32.348Z","dependency_job_id":null,"html_url":"https://github.com/h4kuna/serialize-polyfill","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"dbda0e2b45fd5a201a156f25e984cdc5a4e86395"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4kuna%2Fserialize-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4kuna%2Fserialize-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4kuna%2Fserialize-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4kuna%2Fserialize-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h4kuna","download_url":"https://codeload.github.com/h4kuna/serialize-polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225410692,"owners_count":17470240,"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":["igbinary","php","serialize"],"created_at":"2024-11-19T18:59:20.201Z","updated_at":"2024-11-19T18:59:20.740Z","avatar_url":"https://github.com/h4kuna.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serialization\n\n[![Downloads this Month](https://img.shields.io/packagist/dm/h4kuna/serialize-polyfill.svg)](https://packagist.org/packages/h4kuna/serialize-polyfill)\n[![Latest stable](https://img.shields.io/packagist/v/h4kuna/serialize-polyfill.svg)](https://packagist.org/packages/h4kuna/serialize-polyfill)\n\nIn your project are available two new methods.\n\n - h4kuna\\Serialize\\Serialize::encode()\n - h4kuna\\Serialize\\Serialize::decode()\n\nIf you enable igbinary extension, then automatic use Driver\\IgBinary. Or you can define own implmentation by Driver interface. \n\n## Example why use Serialize class\nIn many use cases is igbinary faster. Anybody use in third party library h4kuna\\Serialize\\Serialize::encode/decode. If you enable igbinary and for this third party case you want to disable and to use standard serialization. See example. \n\nExternal library in vendor\n```php\nnamespace Com\\Example;\n\nuse h4kuna\\Serialize\\Serialize;\n\nclass Foo implements \\Serializable {\n    public function serialize(): ?string {\n        return Serialize::encode($this, __CLASS__);\n    }\n\n    public function unserialize(string $data): void {\n        Serialize::decode($data, __CLASS__);\n        // do anything\n    }\n}\n```\n\nEnable standard serialization for class above.\n\n```php\nuse h4kuna\\Serialize\\Driver;\nuse h4kuna\\Serialize\\Serialize;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\nSerialize::setUp(Driver\\IgBinary::class, [\n    Com\\Example\\Foo::class =\u003e Driver\\Php::class // only for Com\\Example\\Foo use case\n]); \n```\n\n## Compatibility\n\nYou are using php serialize and you want to use igbinary. You can enable igbinaty on fly and old serialized data will be decoded by old php serialize.\n\n\u003e Support compatibility, if you have serialized data by php serialize, then you can decode by IgBinary::decode() and vice versa.\n\n## Enable igbinary\n\n1. Install igbinary extension\n2. \n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\\h4kuna\\Serialize\\Serialize::setUp(IgBinary::class);\n```\n\nWorks!\n\n## Disable igbinary\n\n1. set Php driver after vendor/autoload.php \n```php\nrequire __DIR__ . '/vendor/autoload.php';\n// \\h4kuna\\Serialize\\Serialize::setUp(IgBinary::class); remove\n```\n2. wait if your all data will be decoded\n3. uninstall igbinary extension\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh4kuna%2Fserialize-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh4kuna%2Fserialize-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh4kuna%2Fserialize-polyfill/lists"}