定制 ksfraser/file 二次开发

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

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

ksfraser/file

Composer 安装命令:

composer require ksfraser/file

包简介

File IO helpers with format-aware readers/writers (plus legacy compatibility)

README 文档

README

Format-aware file IO helpers (CSV/JSON/raw) with legacy compatibility.

Installation

composer require ksfraser/file

Core usage (format-aware)

use Ksfraser\File\FileIO;

$io = new FileIO();

// JSON by extension
$io->fput('/tmp/data.json', ['a' => 1]);
$data = $io->fget('/tmp/data.json');

// CSV by extension
$io->fput('/tmp/data.csv', [
    ['a', 'b'],
    ['1', '2'],
]);
$rows = $io->fget('/tmp/data.csv');

URI sanity + transports

FileIO selects a transport by URI scheme:

  • Local files: plain paths like C:/tmp/a.json or file:///C:/tmp/a.json
  • Remote reads: http://... and https://...

Remote writes are rejected.

Bytes + streams

use Ksfraser\File\FileIO;

$io = new FileIO();

$bytes = $io->readBytes('file:///C:/tmp/a.txt');
$io->writeBytes('file:///C:/tmp/b.txt', $bytes);

$stream = $io->streamRead('https://example.com/data.json');
// $stream is typically a PSR-7 stream when guzzle is installed

OO wrappers (legacy-style)

use Ksfraser\File\KsfFile;
use Ksfraser\File\WriteFile;

$f = new KsfFile('a.txt', '/tmp');
$f->open();
$contents = $f->get_all_contents();
$f->close();

$w = new WriteFile('/tmp', 'out.txt');
$w->write_line('hello');
$w->close();

Legacy classes

Legacy class.* implementations remain available under src/Ksfraser/FileLegacy/ and are marked @deprecated. They are kept to avoid breaking older apps, but new development should use Ksfraser\File\*.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固