定制 diseltoofast/php-ninja 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

diseltoofast/php-ninja

Composer 安装命令:

composer require diseltoofast/php-ninja

包简介

PHP library for working with binary data

README 文档

README

This PHP library simplifies working with binary data.

Installation

Requirements

  • PHP 8.0 or higher
  • ext-mbstring

Install via Composer:

composer require diseltoofast/php-ninja

Reading

// Reading from a resource
$binaryData = fopen('example.file', 'rb');
$reader = new \Diseltoofast\PhpNinja\Stream($binaryData);
// Or reading from raw data
$fileData = file_get_contents('example.file');
$reader = new \Diseltoofast\PhpNinja\Stream($fileData);

$intValue = $reader->readInt8(); // Reads a single-byte signed integer
$intValue = $reader->readUInt32(); // Reads a 4-byte unsigned integer
$stringValue = $reader->readString(8); // Reads an 8-byte string
$stringValueUTF16 = $reader->readStringUTF16(8, 'UTF-8'); // Reads an 8-byte string from UTF-16BE or UTF-16LE

Writing

// Writing to a resource
$file = fopen('example.file', 'wb');

$writer = new \Diseltoofast\PhpNinja\Stream($file);
$writer->writeInt8(100); // Writes a single-byte signed integer
$writer->writeUInt32(1000000000); // Writes a 4-byte unsigned integer
$writer->writeString('Hello world!'); // Writes a string
$writer->writeStringUTF16('Привет мир!', 'UTF-8'); // Writes a string in UTF-16BE or UTF-16LE

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-03