定制 intriro/stream 二次开发

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

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

intriro/stream

Composer 安装命令:

composer require intriro/stream

包简介

Provides a simple object-oriented abstraction over streams of data

README 文档

README

Provides a simple object-oriented abstraction over streams of data.

Installation

composer require intriro/stream

Documentation

Stream object by themselves don't have any methods for reading or writing. They just hold a reference to a PHP resource with some convenience methods to get information about the status of the stream.

Create a stream

You can create streams from an existing resource.

$resource = fopen('/home/test/file.txt', 'rw+');

$stream = Stream::createFromResource($resource);

You can also create streams directly from a filename or a URL-style protocol. The URL can be in the format that is supported by fopen.

$stream = Stream::createFromFilename('file:///home/test/file.txt', 'r');
$stream = Stream::createFromUrl('php://temp', 'r');

You can also use the convenience methods provided by the StreamFactory or IoStreamFactory to create streams.

$factory = new StreamFactory();
$stream = $streamFactory->filename(/home/test/file.txt', 'rw+');

$ioStreamFactory = new IoStreamFactory();
$stream = $ioStreamFactory->temp();
$stream = $ioStreamFactory->memory();
$stream = $ioStreamFactory->stdin();
$stream = $ioStreamFactory->stdout();
$stream = $ioStreamFactory->stderr();

Reading and writing to a stream

Manipulation of streams is done through readers and writers.

Reading from a stream

$reader = new Reader(
    Stream::createFromFilename('/home/test/file.txt', 'r')
);

$reader->read(100); // will read 100 bytes from the stream


// Reading lines from a stream
$reader = new LineReader(
    Stream::createFromFilename('/home/test/file.txt', 'r')
);

while($line = $reader->readLine()) {
    // do something
}

Writing to a stream

$ioStreamFactory = new IoStreamFactory();

$writer = new Writer(
    $ioStreamFactory->temp()
);

$writer->write('some text');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固