PHPackages                             trenchdevs/csv - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. trenchdevs/csv

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

trenchdevs/csv
==============

A simple csv wrapper for box/spout package

0504PHP

Since Sep 9Pushed 5y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

trenchdevs/csv
==============

[](#trenchdevscsv)

A simple csv wrapper for box/spout package

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

[](#installation)

Install via composer

`composer require trenchdevs/csv`

Usage
-----

[](#usage)

### Reading Files

[](#reading-files)

`tests/testfiles/valid.csv`

```
id,name,age, tag line,extraheader
1,george,33, "this is my multi line tagline"
2,"Georgie Smith", 31,

```

```
use TrenchDevs\Csv\CsvReader;

try {

    $reader = new CsvReader('/full/file/path'); // eg. __DIR__ . '/tests/testfiles/valid.csv'

    // set the header columns as the headers, use these as the keys for the results while on iteration
    $reader->setFirstRowAsHeaders(true);

    // optional: override headers string, by default it will use columns
    // on csv if setFirstRowAsHeaders is set to true
    $reader->setHeaders(['id', 'name', 'age', 'tagline']);

    foreach ($reader->iterator() as $row) {
        // do something with $row
        //  $row['id'], $row['name'],
        //  $row['age'], $row['tagline'],
    }

} catch (Exception $exception ) {
    // handle
}
```

### Reading and Writing on the same file

[](#reading-and-writing-on-the-same-file)

Coming soon...

Testing
-------

[](#testing)

```
chris@chriss-MacBook-Pro csv % ./vendor/bin/phpunit tests --testdox
PHPUnit 9.3.8 by Sebastian Bergmann and contributors.

Csv Reader
 ✔ Constructor empty file path test
 ✔ Constructor invalid file path test
 ✔ Constructor valid file test
 ✔ Can iterate items with first row as headers
 ✔ Can iterate items
 ✔ Can override headers test
 ✔ Can override headers first row as headers false test

Time: 00:00.009, Memory: 4.00 MB

OK (7 tests, 41 assertions)
```

License
-------

[](#license)

The trenchdevs/csv library is open-sourced software under the [Apache-2.0 License](https://github.com/trenchdevs/csv/blob/master/LICENSE)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

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/5979debbe08e2ba3ed95d64803c2caf297eaa08b39ea1f2e92629061321f4f89?d=identicon)[trenchdevs](/maintainers/trenchdevs)

---

Top Contributors

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

---

Tags

csvphpspout

### Embed Badge

![Health badge](/badges/trenchdevs-csv/health.svg)

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

###  Alternatives

[tarfin-labs/easy-pdf

Makes pdf processing easy.

1719.9k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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