定制 prewk/file-chainer 二次开发

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

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

prewk/file-chainer

最新稳定版本:0.3.0

Composer 安装命令:

composer require prewk/file-chainer

包简介

Chainable file stream writer with insert support

README 文档

README

What is it?

A small wrapper for some php file streaming functions with support for inserting data into streams without overwriting. (Also: chainable.)

Installation

Add to composer:

require: {
    "prewk/file-chainer": "dev-master"
}

And run composer install.

Usage

Two new file stream methods:

  • finsert inserts a string at the current file stream position
  • finsertcsv inserts a csv (like fputcsv) line at the current file stream position

Inserting & chaining

Prewk\FileChainer::make()
    ->fopen("/foo/bar.txt", "w+")
    ->fwrite("foo")
    ->rewind()
    ->finsert("bar")
    ->fclose();

echo file_get_contents("/foo/bar.txt");
// Output: barfoo
// The handle's file pointer = 3

Inserting with static method

$handle = fopen("/foo/bar.txt", "w+");
fwrite($handle, "foo");
rewind($handle);

// Statically, using the default "temporary file stream" method
Prewk\FileChainer\Inserters\File::finsert($handle, "bar");

fclose($handle);

echo file_get_contents("/foo/bar.txt");
// Output: barfoo
// The handle's file pointer = 3

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-28