{"id":14984043,"url":"https://github.com/et-nik/binn-php","last_synced_at":"2025-04-10T19:43:26.905Z","repository":{"id":57007703,"uuid":"57402387","full_name":"et-nik/binn-php","owner":"et-nik","description":"Binary Serialization. PHP Class for serialize to binary string.","archived":false,"fork":false,"pushed_at":"2023-07-20T19:28:09.000Z","size":122,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-06T23:39:42.368Z","etag":null,"topics":["bin","binary","php-library","serialization","symfony-component"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/et-nik.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-29T17:40:35.000Z","updated_at":"2022-04-28T11:43:11.000Z","dependencies_parsed_at":"2024-09-24T15:37:36.526Z","dependency_job_id":null,"html_url":"https://github.com/et-nik/binn-php","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":0.06779661016949157,"last_synced_commit":"401b4d20de0452a34f1549eaff3b677deee0b6d7"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/et-nik%2Fbinn-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/et-nik%2Fbinn-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/et-nik%2Fbinn-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/et-nik%2Fbinn-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/et-nik","download_url":"https://codeload.github.com/et-nik/binn-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281424,"owners_count":21077423,"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":["bin","binary","php-library","serialization","symfony-component"],"created_at":"2024-09-24T14:08:22.112Z","updated_at":"2025-04-10T19:43:26.883Z","avatar_url":"https://github.com/et-nik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Binn\n====\n\n[![Build Status](https://travis-ci.com/et-nik/binn-php.svg?branch=master)](https://travis-ci.comd/et-nik/binn-php)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/et-nik/binn-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/et-nik/binn-php/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/et-nik/binn-php/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/et-nik/binn-php/?branch=master)\n\nPHP Class for serialize to binary string.\n\nOriginal C Binn Library: https://github.com/liteserver/binn\n\nBinn Specification: https://github.com/liteserver/binn/blob/master/spec.md\n\n## Installation\n\n```bash\ncomposer require knik/binn\n```\n\n## Examples\n\n### Binn\n\nSequential arrays:\n\n```php\nuse Knik\\Binn\\Binn;\n\n$binn = new Binn();\n\n// List\n$array = [123, -456, 789];\n$binnString = $binn-\u003eserialize($array);\n$unserialized = $binn-\u003eunserialize($binnString); // Equal with $array\n```\n\nNumeric keys array:\n```php\n$binn = new Binn();\n\n// Map\n$array = [1 =\u003e \"add\", 2 =\u003e [-12345, 6789]];\n$binnString = $binn-\u003eserialize($array);\n$unserialized = $binn-\u003eunserialize($binnString); // Equal with $array\n```\n\nString keys array:\n```php\n$binn = new Binn();\n\n// Object\n$array = [\"hello\" =\u003e \"world\"];\n$binnString = $binn-\u003eserialize($array);\n$unserialized = $binn-\u003eunserialize($binnString); // Equal with $array\n```\n\nMixed arrays:\n\n```php\n$binn = new Binn();\n$array = [ [\"id\" =\u003e 1, \"name\" =\u003e \"John\"], [\"id\" =\u003e 2, \"name\" =\u003e \"Eric\"] ]\n\n// A list of objects\n$binnString = $binn-\u003eserialize($array);\n$unserialized = $binn-\u003eunserialize($binnString); // Equal with $array\n```\n\nBlob:\n```php\n$binn = new Binn();\n$file = fopen('/path/to/file.jpg', 'rb');\n\n// Filedata in binn structure\n$bin1 = $binn-\u003eserialize($file);\n\n// Filedata in binn list structure\n$bin2 = $binn-\u003eserialize(['file' =\u003e $file]);\n```\n\n### Symfony Serializer\n\nYou can use BinnEncoder with Symfony Serializer\n\n```php\nuse Knik\\Binn\\Encoder\\BinnEncoder;\nuse Symfony\\Component\\Serializer\\Serializer;\n\n$encoders = [new BinnEncoder()];\n$serializer = new Serializer([], $encoders);\n\n$serializer-\u003eserialize(\"\\x40\\xD0\\x06\", 'binn');\n```\n\n### Original C library style\n```php\n$binn = new BinnList();\n$binn-\u003eaddUint8(4);\n$binn-\u003eaddInt16(-8875);\n$binn-\u003eaddStr('text');\n\n$serialized = $binn-\u003eserialize(); // \\xE0\\x0F\\x03\\x20\\x04\\x41\\xDD\\x55\\xA0\\x04text\\x00\n\n```\n\n### Nested arrays\n\n```php\n$array = [2, true, [123, -456, 789]];\n\n$binn = new BinnList();\n\n// \\xE0\\x11\\x03\\x20\\x02\\x01\\xE0\\x0B\\x03\\x20\\x7B\\x41\\xFE\\x38\\x40\\x03\\x15\n$serialized = $binn-\u003eserialize($array);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fet-nik%2Fbinn-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fet-nik%2Fbinn-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fet-nik%2Fbinn-php/lists"}