PHPackages                             kaloa/filesystem - 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. kaloa/filesystem

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

kaloa/filesystem
================

Utility classes for tasks related to the filesystem.

v0.2.1(3y ago)288MITPHPPHP &gt;=5.3.0

Since Feb 8Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (4)Used By (0)

kaloa/filesystem
================

[](#kaloafilesystem)

Install
-------

[](#install)

Via Composer:

```
$ composer require kaloa/filesystem
```

Requirements
------------

[](#requirements)

The following PHP versions are supported:

- PHP 5.3
- PHP 5.4
- PHP 5.5
- PHP 5.6
- PHP 7.0
- PHP 7.1
- HHVM

Documentation
-------------

[](#documentation)

### CsvReader

[](#csvreader)

#### Goals

[](#goals)

- Provide an interface to read CSV data from streams into associative arrays.

#### Usage

[](#usage)

Read all CSV rows from a stream into a numeric array. This is also a general usage example.

```
use Kaloa\Filesystem\CsvReader;

$stream = fopen(__DIR__ . '/file.csv', 'rb');

$csvReader = new CsvReader($stream);
$data = $csvReader->fetchAll();

fclose($stream);
```

Read all CSV rows from a stream into an associative array. The first row from the input will be used as keys.

```
$data = $csvReader->fetchAllAssoc();
```

If the file doesn't contain a row with keys, keys can be provided manually. The first row will be seen as regular data.

```
$data = $csvReader->fetchAllAssoc(array('id', 'title', 'date_added'));
```

There’s also a streaming mode available.

```
while ($row = $csvReader->fetch()) {
    // ...
}
```

Streaming works with associative arrays, too. Here, the first call to `fetchAssoc` will transparently read the first two rows from the input to read both the keys and the first data row.

```
while ($row = $csvReader->fetchAssoc()) {
    // ...
}
```

Respectively:

```
while ($row = $csvReader->fetchAssoc(array('id', 'title', 'date_added'))) {
    // ...
}
```

The reader class is intended to always return UTF-8 data. Differing CSV input encodings will be converted automatically if the input encoding is specified in the constructor.

```
$csvReader = new CsvReader($iso88591Stream, 'ISO-8859-1');
```

There’s also support for non-standard delimiter, enclosure and escape characters.

```
$csvReader = new CsvReader($stream, 'UTF-8', ':', '|', '%');
```

#### Further notes

[](#further-notes)

- The `fetch` and `fetchAll` methods accept rows with varying numbers of fields in the same stream. The `fetchAssoc` and `fetchAllAssoc` methods will throw an exception if the number of fields in a row differs from the number of keys.
- It is not possible to change the names of the keys while iterating over input data with `fetchAssoc`. The reader always uses the keys from the first call to `fetchAssoc`.
- Calls to different `fetch*` methods must not be mixed. Currently, the code doesn’t prevent this, but it’s very likely that such functionality will be added in a future release.

#### Recipes

[](#recipes)

For usage with the reader, PHP strings can be converted to streams using the [data protocol](http://php.net/manual/en/wrappers.data.php).

```
$csvString = normalize('./dir1/dir2/dir3/dir4/../../../'); // "dir1"
```

Testing
-------

[](#testing)

(Tools are not included in this package.)

```
$ phpunit
```

Further quality assurance:

```
$ phpcs --standard=PSR2 ./src
$ phpmd ./src text codesize,design,naming
```

Credits
-------

[](#credits)

- [Marc Ermshaus](https://github.com/mermshaus)

License
-------

[](#license)

The package is published under the MIT License. See [LICENSE](https://github.com/mermshaus/kaloa-filesystem/blob/master/LICENSE) for full license info.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~1160 days

Total

3

Last Release

1431d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/09ea55d20cb22b53fa2ad722ce7a6a047d49a965c2df60024a2ac722cebaa313?d=identicon)[mermshaus](/maintainers/mermshaus)

---

Top Contributors

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

---

Tags

filesystemcsvpathsiteratorfilternormalization

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/kaloa-filesystem/health.svg)

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[knplabs/knp-gaufrette-bundle

Allows to easily use the Gaufrette library in a Symfony project

72528.6M91](/packages/knplabs-knp-gaufrette-bundle)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40029.5M87](/packages/league-flysystem-bundle)

PHPackages © 2026

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