定制 shufflingpixels/php-io 二次开发

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

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

shufflingpixels/php-io

最新稳定版本:v0.0.1

Composer 安装命令:

composer require shufflingpixels/php-io

包简介

A small, focused PHP I/O toolkit for working with streams and binary data.

README 文档

README

A small, focused PHP I/O toolkit for working with streams and binary data.

php-io gives you:

  • A consistent StreamInterface abstraction
  • In-memory and file-backed stream implementations
  • A BinaryReader for common integer formats (8/16/32-bit, LE/BE)
  • Clear exception types for I/O and end-of-stream conditions

Requirements

  • PHP >= 8.0

Installation

composer require shufflingpixels/php-io

Quick Start

Read binary values from a string

<?php

use Shufflingpixels\IO\BinaryReader;

$reader = BinaryReader::string("\x34\x12\x80\xff");

$a = $reader->readUInt16LE(); // 0x1234 => 4660
$b = $reader->readInt8();     // -128
$c = $reader->readInt8();     // -1

Work with an in-memory buffer

<?php

use Shufflingpixels\IO\Buffer;
use Shufflingpixels\IO\SeekMode;

$buffer = new Buffer('abcdef');

$buffer->seek(2);                  // position = 2
$buffer->write('XY');              // data becomes: abXYef
$buffer->seek(-2, SeekMode::END);  // position near end

$tail = $buffer->read(2);          // "ef"

Open and use a file stream

<?php

use Shufflingpixels\IO\File;
use Shufflingpixels\IO\FileMode;

$file = File::open('example.bin', FileMode::RW);

$file->write("ABC");
$file->seek(0);

$bytes = $file->read(3); // "ABC"

$file->close();

Main Types

  • Shufflingpixels\IO\StreamInterface: common stream contract (read, write, seek, tell, eof, length)
  • Shufflingpixels\IO\Buffer: in-memory stream implementation
  • Shufflingpixels\IO\File: file-backed stream implementation
  • Shufflingpixels\IO\BinaryReader: typed binary reads over any StreamInterface
  • Shufflingpixels\IO\SeekMode: type-safe seek modes (SET, CUR, END)
  • Shufflingpixels\IO\FileMode: file open modes (READ, WRITE, RW)

Exceptions

  • Shufflingpixels\IO\Exception\IOException: generic stream/file I/O failures
  • Shufflingpixels\IO\Exception\EndOfStreamException: not enough bytes available when reading

Running Tests

This package uses Pest.

composer test

License

AGPL-3.0

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2026-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固