{"id":16877625,"url":"https://github.com/nikic/buffer","last_synced_at":"2025-03-22T07:31:57.815Z","repository":{"id":7462322,"uuid":"8808437","full_name":"nikic/buffer","owner":"nikic","description":"PHP extension for buffer based typed arrays","archived":false,"fork":false,"pushed_at":"2023-01-29T16:54:44.000Z","size":127,"stargazers_count":42,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T09:21:57.509Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikic.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":"2013-03-15T20:34:31.000Z","updated_at":"2024-06-26T03:31:10.000Z","dependencies_parsed_at":"2023-02-16T00:00:49.408Z","dependency_job_id":null,"html_url":"https://github.com/nikic/buffer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Fbuffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Fbuffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Fbuffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Fbuffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikic","download_url":"https://codeload.github.com/nikic/buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244925178,"owners_count":20532873,"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-10-13T15:44:33.003Z","updated_at":"2025-03-22T07:31:57.489Z","avatar_url":"https://github.com/nikic.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Typed array implementation using buffers\n----------------------------------------\n\nThis PHP extension provides typed arrays based on JavaScript's ArrayBuffer interface.\n\nThis extension has been written primarily as a small example for a tutorial and not for its actual\nfunctionality. That's also why it does not contain the full functionality of JS ArrayBuffers. I may\nadd the remaining functionality later on.\n\nUsage\n-----\n\n```php\n\u003c?php\n\n/* First create an ArrayBuffer with a certain size (in this example 8MB). The array buffer itself\n * is just a chunk of binary data with no associated meaning. */\n$buffer = new ArrayBuffer(1024 * 1024 * 8);\n\n/* Create an int32 view on the buffer. This will interpret every four bytes of the buffer as one\n * signed 32-bit integer. It can be used as a normal array (obviously only in the allowed range) */\n$int32s = new Int32Array($buffer);\n\n$int32s[0] = 1234;\nvar_dump($int32s[0]); // int(1234)\n\n/* We can interpret the *same* buffer in a different way, namely as an array of floats */\n$floats = new FloatArray($buffer);\n\n/* Here for example we are reinterpreting the 1234 int32 integer as a single-precision floating\n * point number. */\nvar_dump($floats[0]); // float(1.7292023049768E-42)\n\n/* It is also possible to restrict the view to a certain part of the buffer. E.g. here we create\n * an unsigned 16-bit integer view that starts 32 bytes into the buffer and contains 1024 elements.\n */\n$uint16s = new UInt16Array($buffer, 32, 1024);\n```\n\nThe following buffer views are available:\n\n    Int8Array\n    UInt8Array\n    Int16Array\n    Uint16Array\n    Int32Array\n    UInt32Array\n    FloatArray\n    DoubleArray\n\nSee `tests/` for more examples.\n\nInstallation\n------------\n\nThe extension is installed as usual:\n\n    phpize\n    ./configure --enable-buffer\n    make\n    make install\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikic%2Fbuffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikic%2Fbuffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikic%2Fbuffer/lists"}