{"id":13699945,"url":"https://github.com/igbinary/igbinary","last_synced_at":"2025-05-04T18:33:53.944Z","repository":{"id":1295451,"uuid":"1237364","full_name":"igbinary/igbinary","owner":"igbinary","description":"Igbinary is a drop in replacement for the standard php serializer.","archived":false,"fork":true,"pushed_at":"2024-08-11T17:50:49.000Z","size":1172,"stargazers_count":761,"open_issues_count":20,"forks_count":66,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-11-13T06:32:50.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"somia/igbinary","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igbinary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2011-01-10T08:47:54.000Z","updated_at":"2024-11-10T11:13:29.000Z","dependencies_parsed_at":"2023-07-06T06:03:41.333Z","dependency_job_id":null,"html_url":"https://github.com/igbinary/igbinary","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igbinary%2Figbinary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igbinary%2Figbinary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igbinary%2Figbinary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igbinary%2Figbinary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igbinary","download_url":"https://codeload.github.com/igbinary/igbinary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382805,"owners_count":21739216,"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":[],"created_at":"2024-08-02T20:00:46.283Z","updated_at":"2025-05-04T18:33:52.534Z","avatar_url":"https://github.com/igbinary.png","language":"PHP","funding_links":[],"categories":["数据转换"],"sub_categories":[],"readme":"igbinary\n========\n\n[![Build Status](https://github.com/igbinary/igbinary/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/igbinary/igbinary/actions/workflows/main.yml?query=branch%3Amaster)\n[![Build Status (Windows)](https://ci.appveyor.com/api/projects/status/suhkkumj1yh9dgan?svg=true)](https://ci.appveyor.com/project/TysonAndre/igbinary-bemsx)\n\nIgbinary is a drop in replacement for the standard php serializer.\nInstead of the time and space consuming textual representation used by PHP's `serialize`,\nigbinary stores php data structures in a compact binary form.\nMemory savings are significant when using memcached, APCu, or similar memory based storages for serialized data.\nThe typical reduction in storage requirements are around 50%.\nThe exact percentage depends on your data.\n\nUnserialization performance is [at least on par with the standard PHP serializer, and is much faster for repetitive data](benchmark/comparisons.php).\nSerialization performance depends on the `igbinary.compact_strings` option which enables\nduplicate string tracking.\nString are inserted to a hash table, which adds some overhead when serializing.\nIn usual scenarios this does not have much of an impact,\nbecause the typical usage pattern is \"serialize rarely, unserialize often\".\nWith the `compact_strings` option enabled,\nigbinary is usually a bit slower than the standard serializer.\nWithout it, igbinary is a bit faster.\n\nFeatures\n--------\n\n- Support for the same data types as the standard PHP serializer: null, bool, int,\n  float, string, array and object.\n- `__autoload` \u0026 `unserialize_callback_func`\n- `__sleep` \u0026 `__wakeup`\n- `__serialize` \u0026 `__unserialize` (only used in php 7.4+)\n- Serializable -interface\n- Data portability between platforms (32/64bit, endianness)\n- Tested on Linux amd64, Linux ARM, Mac OSX x86, HP-UX PA-RISC and NetBSD sparc64\n- Hooks up to the APCu in-memory key-value store as a serialization handler.\n- Compatible with 7.0 \u0026ndash; 8.0 (The older igbinary [2.x releases](https://github.com/igbinary/igbinary/tree/v2) support 5.2 \u0026ndash; 5.6, 7.0 \u0026ndash; 7.3)\n\nImplementation details\n----------------------\n\nStoring complex PHP data structures such as arrays of associative arrays\nwith the standard PHP serializer is not very space efficient.\nThe main reasons of this inefficiency are listed below, in order of significance (at least in our applications):\n\n1. Array keys, property names, and class names are repeated redundantly.\n2. Numerical values are plain text.\n3. Human readability adds some overhead.\n\nIgbinary uses two strategies to minimize the size of the serialized\noutput.\n\n1. Repeated strings are stored only once (this also includes class and property names).\n   Collections of objects benefit significantly from this.\n   See the `igbinary.compact_strings` option.\n\n2. Integer values are stored in the smallest primitive data type available:\n    *123* = `int8_t`,\n    *1234* = `int16_t`,\n    *123456* = `int32_t`\n ... and so on.\n\n3. ( Well, it is not human readable ;)\n\nHow to use\n----------\n\nAdd the following lines to your php.ini:\n\n```ini\n; Load igbinary extension\nextension=igbinary.so\n\n; Use igbinary as session serializer\nsession.serialize_handler=igbinary\n\n; Enable or disable compacting of duplicate strings\n; The default is On.\nigbinary.compact_strings=On\n\n; If uncommented, use igbinary as the serializer of APCu\n; (APCu 5.1.10 or newer is strongly recommended)\n;apc.serializer=igbinary\n```\n\nThen, in your php code, replace `serialize` and `unserialize` function calls\nwith [`igbinary_serialize` and `igbinary_unserialize`](./igbinary.php).\n\nInstalling\n----------\n\n### Linux\n\nIf PHP was installed through your package manager,\nthe package manager may also contain prebuilt packages for `igbinary`\n(with a package name similar to php-igbinary).\n\n- The packages from some package managers and OS versions may be out of date and have known bugs. The latest release of igbinary is [![The Latest Stable Version](https://img.shields.io/github/v/release/igbinary/igbinary.svg)](https://github.com/igbinary/igbinary/releases)\n\nIgbinary may also be installed with the command `pecl install igbinary` (You will need to enable igbinary in php.ini)\n\nAlternately, you may wish to [build from source](#building-from-source)\n\n### MacOS\n\n`pecl install igbinary` is the recommended installation method (You will need to enable igbinary in php.ini)\n\nAlternately, you may wish to [build from source](#building-from-source).\n\n### Installing on Windows\n\nPrebuilt DLLs can be [downloaded from PECL](https://pecl.php.net/package/igbinary).\n\nIf you are a contributor to/packager of igbinary, or need to build from source, see [WINDOWS.md](./WINDOWS.md)\n\n### Building from source\n\n1. `phpize`\n2. `./configure`\n\n    - With GCC: `./configure CFLAGS=\"-O2 -g\" --enable-igbinary`\n    - With ICC (Intel C Compiler) `./configure CFLAGS=\" -no-prec-div -O3 -xO -unroll2 -g\" CC=icc --enable-igbinary`\n    - With clang: `./configure CC=clang CFLAGS=\"-O0 -g\" --enable-igbinary`\n3. `make`\n4. `make test`\n5. `make install`\n6. `igbinary.so` is installed to the default extension directory\n\nBugs \u0026 Contributions\n--------------------\n\nMailing list for bug reports and other development discussion can be found\nat http://groups.google.com/group/igbinary (no longer used)\n\nFile bug reports at\nhttps://github.com/igbinary/igbinary/issues\n\nThe preferred way to contribute is with pull requests.\nFeel free to fork this at http://github.com/igbinary/igbinary\n\nSee [TESTING.md](./TESTING.md) for advice for testing patches.\n\nSee [TECH\\_NOTES.md](./TECH_NOTES.md) for information about how igbinary is implemented\n\nUtilizing in other extensions\n-----------------------------\n\nIgbinary can be called from other extensions fairly easily. Igbinary installs\nits header file to _ext/igbinary/igbinary.h_. There are just two straightforward\nfunctions: `igbinary_serialize` and `igbinary_unserialize`. Look at _igbinary.h_ for\nprototypes and usage.\n\nAdd `PHP_ADD_EXTENSION_DEP(yourextension, igbinary)` to your _config.m4_ in case\nsomeone wants to compile both of them statically into php.\n\nTrivia\n------\n\nWhere does the name \"igbinary\" come from? There was once a similar project\ncalled fbinary but it has disappeared from the Internet a long time ago. Its\narchitecture wasn't particularly clean either. IG is an abbreviation for a\nFinnish social networking site IRC-Galleria (http://irc-galleria.net/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figbinary%2Figbinary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figbinary%2Figbinary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figbinary%2Figbinary/lists"}