PHPackages                             faustvik/text-files - 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. faustvik/text-files

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

faustvik/text-files
===================

PHP library for reading, writing and processing text files and CSV with a clean contract-based API

v0.2.0(1w ago)03MITPHPPHP &gt;=8.1

Since Mar 5Pushed 1w ago1 watchersCompare

[ Source](https://github.com/FaustVik/text-files)[ Packagist](https://packagist.org/packages/faustvik/text-files)[ RSS](/packages/faustvik-text-files/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (14)Versions (8)Used By (0)

Text Files
==========

[](#text-files)

PHP library for reading, writing and processing text files and CSV.

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

[](#installation)

```
composer require faustvik/text-files
```

**Requirements:** PHP &gt;= 8.1, ext-json **Optional:** ext-posix (for `FileInfo::getFileOwner()`)

Quick Start
-----------

[](#quick-start)

### Text Files

[](#text-files-1)

```
use FaustVik\Files\Text\TextFileManager;

$text = TextFileManager::fromPath('/path/to/file.txt');

// Read
$lines = $text->readToArray();
$content = $text->readToString();
$count = $text->count();

// Write
$text->write('appended content');
$text->overWrite('new content');
$text->appendToStartFile('prepended content');

// Search & modify
$found = $text->search('keyword');          // case-insensitive
$text->replaceLine(2, 'new line content');
$text->deleteLine(0);

// Memory-efficient iteration
foreach ($text->lines() as $index => $line) {
    echo $line;
}
```

Skip empty lines:

```
$text = TextFileManager::fromPath('/path/to/file.txt', skipEmptyLines: true);
```

### CSV Files

[](#csv-files)

```
use FaustVik\Files\Csv\CsvManager;

$csv = CsvManager::fromPath('/path/to/data.csv');

// Read
$data = $csv->read();
$headers = $csv->getHeadersColumn();
$count = $csv->count();

// Write
$csv->write([['id' => 1, 'name' => 'Alice', 'age' => 30]]);
$csv->overWrite($allData);

// Row operations
$csv->insertLine(['3', 'Charlie', '35'], 1);
$csv->deleteLine([0, 2]);

// Column operations
$csv->addColumn('status', 'active');
$csv->addColumn('id', '0', position: 0);   // insert at specific position
$csv->deleteColumn([1]);
$csv->updateHeaders(['ID', 'Full Name', 'Age']);
$csv->getColumns([0, 2]);

// Filter & search
$csv->filterByColumn(2, '30');
$csv->filter(fn(array $row): bool => (int) $row[2] > 25);
$csv->search('Alice');
$csv->search('New York', columnIndex: 2);

// Transform
$names = $csv->map(fn(array $row): string => $row[1]);

// Streaming (memory-efficient)
$csv->stream(function (array $row): ?bool {
    echo implode(', ', $row) . "\n";
    return true; // return false to stop
});

$csv->chunk(100, function (array $rows): ?bool {
    processRows($rows);
    return true;
});
```

CSV settings:

```
$csv = CsvManager::fromPath(
    path: '/path/to/data.csv',
    separator: ';',
    skipFirstLine: true,
    escapeChar: '\\',
    enclosureChar: '"',
);
```

Helpers
-------

[](#helpers)

Standalone utility classes for common file system operations.

### FileInfo

[](#fileinfo)

```
use FaustVik\Files\Helpers\File\FileInfo;

FileInfo::getName('/path/to/file.txt');     // 'file.txt'
FileInfo::getSize('/path/to/file.txt');     // size in bytes
FileInfo::getExtension('/path/to/file.txt'); // 'txt'
FileInfo::isReadable('/path/to/file.txt');  // true/false
FileInfo::isWritable('/path/to/file.txt');  // true/false
FileInfo::isFile('/path/to/file.txt');      // true/false
FileInfo::getFileTime('/path/to/file.txt'); // modification timestamp
FileInfo::getFileOwner('/path/to/file.txt'); // requires ext-posix
```

### FileOperation

[](#fileoperation)

```
use FaustVik\Files\Helpers\File\FileOperation;

FileOperation::copy('/from.txt', '/to.txt');
FileOperation::move('/from.txt', '/to.txt');
FileOperation::rename('/path/to/file.txt', 'newname.txt');
FileOperation::delete('/path/to/file.txt');
FileOperation::flush('/path/to/file.txt');  // clear file content
```

### DirectoryInfo &amp; DirectoryOperation

[](#directoryinfo--directoryoperation)

```
use FaustVik\Files\Helpers\Directory\DirectoryInfo;
use FaustVik\Files\Helpers\Directory\DirectoryOperation;
use FaustVik\Files\Helpers\Directory\EnumSortDirectory;

DirectoryInfo::scan('/path/to/dir', EnumSortDirectory::Asc);
DirectoryInfo::isDirExist('/path/to/dir');

DirectoryOperation::createDir('/path/to/dir', recursive: true);
DirectoryOperation::deleteDir('/path/to/dir');
```

Exceptions
----------

[](#exceptions)

All exceptions extend `BaseTextFileException`:

- `FileNotFoundException` — file does not exist
- `FileIsNotReadableException` — file is not readable
- `FileIsNotWriteableException` — file is not writable
- `FileExtensionIsNotSupportedException` — unsupported file extension (e.g. non-CSV)
- `CantReadFileException` — read operation failed
- `IsNotResourceException` — expected a resource, got something else
- `DirectoryExceptionBase` — directory operation failed

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance98

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

Total

4

Last Release

12d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/40139807?v=4)[Victor Degtyarev](/maintainers/FaustVik)[@FaustVik](https://github.com/FaustVik)

---

Top Contributors

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

---

Tags

phpstreamingcsvfilefilestextfile managerfile-operationscsv writercsv readertext file

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/faustvik-text-files/health.svg)

```
[![Health](https://phpackages.com/badges/faustvik-text-files/health.svg)](https://phpackages.com/packages/faustvik-text-files)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

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

AWS S3 filesystem adapter for Flysystem.

1.7k293.8M1.2k](/packages/league-flysystem-aws-s3-v3)[blueimp/jquery-file-upload

File Upload widget for jQuery.

141.5M20](/packages/blueimp-jquery-file-upload)

PHPackages © 2026

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