PHPackages                             hhpack/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. hhpack/file

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

hhpack/file
===========

File utility library for Hack

1.2.2(8y ago)13MITHack

Since Oct 11Pushed 8y agoCompare

[ Source](https://github.com/hhpack/file)[ Packagist](https://packagist.org/packages/hhpack/file)[ RSS](/packages/hhpack-file/feed)WikiDiscussions master Synced 3w ago

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

file
====

[](#file)

[![Latest Stable Version](https://camo.githubusercontent.com/c1e0f87be92052a71f8c56015281163490e4dddc222197c8ae9e7eb1198f60e4/68747470733a2f2f706f7365722e707567782e6f72672f68687061636b2f66696c652f762f737461626c65)](https://packagist.org/packages/hhpack/file)[![Build Status](https://camo.githubusercontent.com/b413370483ca1590c7bfdc17adbfa981846db175029866aa393e32596375caef/68747470733a2f2f7472617669732d63692e6f72672f68687061636b2f66696c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hhpack/file)[![Dependency Status](https://camo.githubusercontent.com/ea8364de19b6feb10587257245091d962e847004e5e2b9a8d6c9d77c4c37e845/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3536323339646236333664306162303031363030306265382f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/56239db636d0ab0016000be8)[![License](https://camo.githubusercontent.com/e778e74104f5efeba74eb122480f3cc7326de3d4989932271bf1a9aeda110cd4/68747470733a2f2f706f7365722e707567782e6f72672f68687061636b2f66696c652f6c6963656e7365)](https://packagist.org/packages/hhpack/file)

This package is a library for performing a simple to file operations hacklang.
Will provide a lightweight and simple api to the user.

Basic usage
-----------

[](#basic-usage)

Read processing of files can be realized by a simple code as follows.

### Reading one line at a time.

[](#reading-one-line-at-a-time)

```
use HHPack\File\FileLineStream;

$lineStream = FileLineStream::fromString('/path/to/text.log');

foreach ($lineStream as $line) {
	echo $line->length(), "\n"; //output length
	echo $line->value(), "\n"; //output content
};
```

Read the CSV file
-----------------

[](#read-the-csv-file)

```
use HHPack\File\FileLineStream;
use HHPack\File\SeparatedRecordStream;
use HHPack\File\ColumnSpecification;

$spec = new ColumnSpecification(',', '"');
$spec->addColumn(0, 'name');
$spec->addColumn(1, 'description');

$lineStream = FileLineStream::fromString(__DIR__ . '/example.csv');
$csvStream = new SeparatedRecordStream($lineStream, $spec);

foreach ($csvStream as $record) {
    echo $record->get('name'), "\n";
    echo $record->get('description'), "\n";
}
```

Customizing the reading of the record
-------------------------------------

[](#customizing-the-reading-of-the-record)

Will create a parser that implements the **ParseSpecification**.
Then use the **ParsedFileReader**, and then apply the parser.

```
use HHPack\File\FileLineStream;
use HHPack\File\ParsedChunkStream;
use HHPack\File\ParseSpecification;

final class CustomRecordSpecification implements ParseSpecification
{
    public function parse(Chunk $line) : array
    {
        return $line->split(',');
    }
}

$spec = new CustomRecordSpecification();
$lineStream = FileLineStream::fromString(__DIR__ . '/example.csv');
$csvStream = new ParsedChunkStream($lineStream, $spec);

foreach ($csvStream as $values) {
    echo $values[0], "\n";
    echo $values[1], "\n";
}
```

Run the test
------------

[](#run-the-test)

You can run the test with the following command.

```
composer install
composer test

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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 ~51 days

Recently: every ~21 days

Total

15

Last Release

3186d ago

Major Versions

0.5.0 → 1.0.02017-02-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/70c299d6d6015ee714954aa05e4d0e9c7b1d31318a5d7db5e9bb4e1f70f78afc?d=identicon)[holyshared](/maintainers/holyshared)

---

Top Contributors

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

---

Tags

csvfieldhacklanghhvmutilityfileSimplehackeasy

### Embed Badge

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

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k665.7M2.4k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k277.8M959](/packages/league-flysystem-aws-s3-v3)[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k40.9M129](/packages/knplabs-gaufrette)[knplabs/knp-gaufrette-bundle

Allows to easily use the Gaufrette library in a Symfony project

72429.6M99](/packages/knplabs-knp-gaufrette-bundle)[league/flysystem-local

Local filesystem adapter for Flysystem.

224254.9M71](/packages/league-flysystem-local)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8535.9M247](/packages/league-flysystem-memory)

PHPackages © 2026

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