dmitriynyu/chunked-file-reader
Composer 安装命令:
composer require dmitriynyu/chunked-file-reader
包简介
Class ChunkedFileReader helps you to read content from text files without loading whole file contents in RAM.
README 文档
README
Class ChunkedFileReader helps you to read content from text files without loading whole file contents in RAM. It implements a SeekableIterator and allows you to read file chunk by chunk.
Warning!
If you have 32-bit installation of PHP, this class won't work with files large than 2 gigabytes. Use 64-bit and check value of PHP_INT_MAX - this is maximum in bytes that you will be able to traverse. See fseek() for more details on this problem.
Installation
Use Composer to install package or download and include files manually to your project.
Usage
Make sure ChunkedFileReader is installed and available in your namespace. You can traverse file whatever way you prefer. You should have class than can handle and process chunks.
$chunkSize = 128; $reader = new ChunkedFileReader($path, $chunkSize); $chunkParser = new MyCustomChunkParserThatKnowsWhatToDoWithChunks(); foreach($reader as $chunkPosition => $chunk) { // chunks will contain 128 bytes of data // in order of appearance until EOF $chunkParser->process($chunk) }
Development
This package needs improvement, any contribution is welcomed.
License
MIT
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-23