zenstruck/stream 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

zenstruck/stream

最新稳定版本:v1.3.0

Composer 安装命令:

composer require zenstruck/stream

包简介

Object wrapper for PHP resources.

README 文档

README

CI Status codecov

Object wrapper for PHP resources.

Installation

composer require zenstruck/stream

API

Create Stream Object

use Zenstruck\Stream;

// wrap
$stream = Stream::wrap($resource);
$stream = Stream::wrap('string');
$stream = Stream::wrap($stream);

// open
$stream = Stream::open('some/file.txt', 'r');

// php://memory
$stream = Stream::inMemory();

// php://output
$stream = Stream::inOutput();

// \tmpfile()
$stream = Stream::tempFile();

// autoclose on $stream __destruct
$stream->autoClose(); // Stream

Use Stream Object

/** @var \Zenstruck\Stream $stream */

// metadata
$stream->id(); // int - the resource id
$stream->type(); // string - the resource type
$stream->metadata(); // array - the resources metadata
$stream->metadata('wrapper_type'); // mixed - specific resource metadata key
$stream->uri(); // string - shortcut for `$stream->metadata('uri')`

// read
$stream->get(); // resource - the raw, wrapped resource
$stream->contents(); // string - the contents of the resource (auto-rewound)

// write
$stream->write($resource); // self - write another resource to the stream
$stream->write('string'); // self - write a string to the stream
$stream->write($anotherStream); // self - write another \Zenstruck\Stream instance to the stream

// manipulate
$stream->close(); // no-return - close the resource (if open)
$stream->rewind(); // self - rewind the stream

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-05