PHPackages                             ksfraser/file - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. ksfraser/file

ActiveLibrary[File &amp; Storage](/categories/file-storage)

ksfraser/file
=============

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

00PHP

Since Feb 14Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ksfraser/FILE)[ Packagist](https://packagist.org/packages/ksfraser/file)[ RSS](/packages/ksfraser-file/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Ksfraser File
=============

[](#ksfraser-file)

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

Installation
------------

[](#installation)

```
composer require ksfraser/file
```

Core usage (format-aware)
-------------------------

[](#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
-----------------------

[](#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
---------------

[](#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)
--------------------------

[](#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-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\*`.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance55

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8870cc04b29a973eed9ad367a936ab274d744de37ff0c35fa0540a932905271?d=identicon)[ksfraser](/maintainers/ksfraser)

---

Top Contributors

[![ksfraser](https://avatars.githubusercontent.com/u/54461925?v=4)](https://github.com/ksfraser "ksfraser (4 commits)")

### Embed Badge

![Health badge](/badges/ksfraser-file/health.svg)

```
[![Health](https://phpackages.com/badges/ksfraser-file/health.svg)](https://phpackages.com/packages/ksfraser-file)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
