Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akmalfairuz/php-ext-bytebuf
ByteBuf Extension for PHP
https://github.com/akmalfairuz/php-ext-bytebuf
minecraft php pmmp pocketmine
Last synced: about 1 month ago
JSON representation
ByteBuf Extension for PHP
- Host: GitHub
- URL: https://github.com/akmalfairuz/php-ext-bytebuf
- Owner: AkmalFairuz
- License: mit
- Created: 2024-08-17T04:11:01.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-18T05:09:15.000Z (3 months ago)
- Last Synced: 2024-10-09T23:03:12.422Z (about 1 month ago)
- Topics: minecraft, php, pmmp, pocketmine
- Language: C++
- Homepage:
- Size: 80.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ByteBuf extension for PHP
This extension provides a high performance byte buffer implementation for PHP. Replacement for `pack()`, `unpack()`, and [pmmp/BinaryUtils](https://github.com/pmmp/BinaryUtils)
⚠️ **This extension is still under development. There is a possibility that this extension will crash or behave incorrectly.**
## Performance
- ByteBuf uses exponential growth for buffer size to prevent frequent memory allocation.
- `LE` & `BE` performance is ~2x faster than `pack()` and `unpack()`### Comparison with [pmmp/BinaryUtils](https://github.com/pmmp/BinaryUtils)
- `ByteBuf->read` and `ByteBuf->write` performance is ~2x faster
- VarInt reading and writing performance is ~9x faster
- Triad reading and writing performance is ~3x faster### Comparison with [pmmp/ext-encoding](https://github.com/pmmp/ext-encoding)
- `ByteBuf->read` performance is ~1.5x faster## Documentation
Self-explanatory, see [bytebuf.stub.php](bytebuf.stub.php) and [tests](tests)## TODO
- Reusable ByteBuf to reduce memory allocation
- More tests## How to build?
1. Make sure you have PHP development environment installed and downloaded the PHP Source Code. See: [Windows](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2), [Linux](https://github.com/php/php-src?tab=readme-ov-file#building-php-source-code)
2. Clone this repository to `/path/to/php-src/ext/bytebuf`
3. To build on Windows, you need to run terminal via `phpsdk-vs17-x64.bat`. Run the following commands:
```bash
cd /path/to/php-srcbuildconf
./configure --enable-bytebuf (...other options)
make # For Linux
nmake # For Windows
```