PHPackages                             aymericcucherousset/csv-helper - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. aymericcucherousset/csv-helper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aymericcucherousset/csv-helper
==============================

Simplify CSV with php

v0.0.1(6mo ago)00MITPHPPHP &gt;8.3CI passing

Since Nov 1Pushed 6mo agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

CSV Helper
==========

[](#csv-helper)

A small PHP library to read, hydrate and write CSV files with a convenient API.

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

[](#requirements)

- PHP 8.3+
- Composer (for installing dev deps and running scripts)

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

[](#installation)

Install dependencies with Composer:

```
composer require aymericcucherousset/csv-helper
```

Usage examples
--------------

[](#usage-examples)

The library provides three main helpers: a reader, a hydrator and a writer.

CsvReader
---------

[](#csvreader)

Read rows from a CSV file. By default the reader expects a header row.

```
use Aymericcucherousset\CsvHelper\Reader\CsvReader;
use Aymericcucherousset\CsvHelper\Options\CsvOptions;

$reader = CsvReader::fromPath('/path/to/file.csv', new CsvOptions(hasHeader: true));
foreach ($reader->rows() as $row) {
    // $row is an associative array when hasHeader=true
    var_dump($row);
}
```

CsvHydrator
-----------

[](#csvhydrator)

Hydrate rows into objects using PHP attributes (CsvColumn) or header-to-property mapping.

```
use Aymericcucherousset\CsvHelper\Hydrator\CsvHydrator;

$hydrator = new CsvHydrator($reader);
foreach ($hydrator->hydrate(MyClass::class) as $obj) {
    // $obj is an instance of MyClass
}

// or load all into memory
$all = $hydrator->hydrateAll(MyClass::class);
```

CsvWriter
---------

[](#csvwriter)

Write indexed rows or arrays of objects to CSV. Accepts iterable rows including Traversable (ArrayIterator) and generators.

```
use Aymericcucherousset\CsvHelper\Writer\CsvWriter;
use Aymericcucherousset\CsvHelper\Options\CsvOptions;

$writer = CsvWriter::fromPath('/tmp/out.csv', new CsvOptions(), false);
$writer->writeRows([
    ['Alice', '30'],
    ['Bob', '25'],
], ['name','age']);

// write objects by property or getters
$writer->writeObjects([$obj1, $obj2], ['name','age'], ['name','age']);
```

Notes on behavior
-----------------

[](#notes-on-behavior)

- `CsvReader::rows()` yields associative arrays when `hasHeader=true`, else indexed arrays.
- Empty CSV lines: when `skipEmptyLines` is true (default) empty rows are skipped. Tests demonstrate behavior when `skipEmptyLines=false`.
- `CsvHydrator` supports converters via attribute configuration and basic builtin casting for scalar typed properties (int, float, bool, string).
- `CsvWriter::writeRows()` supports rows that are `\Traversable` (they are converted with `iterator_to_array`).

Contributing
------------

[](#contributing)

This README is intended for users of the library. If you'd like to contribute, please read the full contributor guidelines in `CONTRIBUTING.md` which explains the PR process, testing, coding standards and useful commands.

Quick checklist for contributors:

- Run the test suite: `composer test` or `vendor/bin/phpunit`.
- Run static analysis: `composer phpstan`.
- Run style checks and fix: `composer lint` / `composer lint-fix`.
- Add unit tests for any new behavior or bug fix.

Then open a pull request explaining the change and the added tests.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance72

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

189d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e5233371c649b785f2b726ec2ec837d143dc7f5c3e801ae2dd0838faaa2fd5d?d=identicon)[aymericcucherousset](/maintainers/aymericcucherousset)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[robinherbots/jquery.inputmask

Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.

6.5k276.6k4](/packages/robinherbots-jqueryinputmask)[webman/captcha

Captcha generator

1484.2k25](/packages/webman-captcha)

PHPackages © 2026

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