gravitymedia/stream
Composer 安装命令:
composer require gravitymedia/stream
包简介
Stream is an object oriented library for reading and writing binary streams in PHP.
README 文档
README
Stream is an object oriented library for reading and writing binary streams in PHP.
Requirements
This library has the following requirements:
- PHP 5.6+
Installation
Install Composer in your project:
$ curl -s https://getcomposer.org/installer | php
Add the package to your composer.json and install it via Composer:
$ php composer.phar require gravitymedia/stream
Usage
This is a simple usage example for character streams but is applicable for binary data streams.
require 'vendor/autoload.php'; use GravityMedia\Stream\Stream; // create resource $resource = fopen('php://temp', 'r+'); // create new stream object $stream = Stream::fromResource($resource); // write some data $stream->write("\x63\x6f\x6e\x74\x65\x6e\x74\x73"); // seek a position $stream->seek(4); // print 32 bit unsigned integer print $stream->readUInt32() . PHP_EOL; // rewind stream $stream->rewind(); // print the data previously written while (!$stream->eof()) { print $stream->read(1); } print PHP_EOL; // print position print $stream->tell() . PHP_EOL; // rewind stream $stream->rewind(); // truncate random data $stream->truncate(7); // print the truncated data while (!$stream->eof()) { print $stream->read(1); } print PHP_EOL;
Testing
Clone this repository, install Composer and all dependencies:
$ php composer.phar install
Run the test suite:
$ php vendor/bin/phing test
Generating documentation
Clone this repository, install Composer and all dependencies:
$ php composer.phar install
Generate the documentation to the build/docs directory:
$ php vendor/bin/phing doc
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 89
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-24