PHPackages                             fusonic/csv-reader - 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. fusonic/csv-reader

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

fusonic/csv-reader
==================

Map data from CSV files to typed PHP models.

0.5.2(7mo ago)1090.1k↓47.3%3MITPHPPHP &gt;=8.2

Since Feb 9Pushed 2mo ago9 watchersCompare

[ Source](https://github.com/fusonic/php-csv-reader)[ Packagist](https://packagist.org/packages/fusonic/csv-reader)[ RSS](/packages/fusonic-csv-reader/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (10)Versions (14)Used By (0)

CSV Reader
==========

[](#csv-reader)

[![License](https://camo.githubusercontent.com/0f5cd7878aab63d1c050cf2ba5a6215411695084b93ef944f3367e2af1bd1390/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6675736f6e69632f6373762d7265616465723f636f6c6f723d626c7565)](https://github.com/fusonic/php-csv-reader/blob/master/LICENSE)[![Latest Version](https://camo.githubusercontent.com/9cafaa9181a74f61e63b4ca8862ecf618968153c2220b8e5444bccfc2da57a41/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6675736f6e69632f7068702d6373762d7265616465722e7376673f636f6c6f723d626c7565)](https://github.com/fusonic/php-csv-reader/releases)[![Total Downloads](https://camo.githubusercontent.com/3759c85148174e945a06b22cde93e9c8d48c98c09795134c9b81ce1d18827b74/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6675736f6e69632f6373762d7265616465722e7376673f636f6c6f723d626c7565)](https://packagist.org/packages/fusonic/csv-reader)[![php 8.2+](https://camo.githubusercontent.com/9e7de8f53fac1ec010865f815f97a686fa5e28543ee713cfe5c17e019cba1e77/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d6d696e253230382e302d626c75652e737667)](https://camo.githubusercontent.com/9e7de8f53fac1ec010865f815f97a686fa5e28543ee713cfe5c17e019cba1e77/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d6d696e253230382e302d626c75652e737667)

CSV Reader is a powerful library for PHP 8 that allows you to map data from CSV files to a strongly typed data model. It does this by utilizing PHP 8's typed properties / arguments and automatically converts string values to the types defined for your class fields.

Install
-------

[](#install)

Use composer to install the lib from Packagist.

```
composer require fusonic/csv-reader
```

Requirements:

- PHP 8.2+

Usage
-----

[](#usage)

Just define a class that represents your CSV's data structure and use the [`IndexMapping`](src/Attributes/IndexMapping.php) or [`TitleMapping`](src/Attributes/TitleMapping.php) attributes to define the mapping. You don't have to map all the columns, just the ones you need on your model.

```
class Foo
{
    #[TitleMapping('Price')]
    public float $price;

    #[TitleMapping('Price')]
    public function setPrice(float $value): void
    {
        // Not implemented
    }
}
```

Now use the `CsvReader` class to convert CSV data to your object model:

```
$reader = new CsvReader('myfile.csv');
foreach ($reader->readObjects(Foo::class) as $item) {
    var_dump($item);
}
```

**Hint:** You can also pass a `resource` instead of a file's path to `CsvReader`. This way you can also access files from remote filesystems, for example if you are using [`league/flysystem`](https://github.com/thephpleague/flysystem).

Supported types
---------------

[](#supported-types)

- `int`
- `float`
- `string`
- `bool` (uses `filter_var()` with `FILTER_VALIDATE_BOOLEAN` and supports values like `on`, `true`, `1`)
- `DateTime`
- `DateTimeInterface`
- `DateTimeImmutable`

If you choose to use a \*\*nullable type like `?string``** it will be mapped as `null` if the CSV value is an empty string or 'null' (case insensitive).

Options
-------

[](#options)

Refer to the [`CsvReaderOptions`](src/CsvReaderOptions.php) class to learn about options.

### `IntlValueConverter`

[](#intlvalueconverter)

If you need to unserialize floating point numbers from a specific culture, you can use the `IntlValueConverter` like this:

```
$options = new CsvReaderOptions();
$options->valueConverter = new IntlValueConverter('de-AT');

$reader = new CsvReader($options);
```

**Note:** parsing German date format is done implicitely by the default `ValueConverter` implementation since PHP supports passing German date formats to `DateTimeInterface` derivates.

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

[](#contributing)

This is a subtree split of [fusonic/php-extensions](https://github.com/fusonic/php-extensions) repository. Please create your pull requests there.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance75

Regular maintenance activity

Popularity38

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

12

Last Release

212d ago

PHP version history (3 changes)0.1.0PHP &gt;=8.0

0.3.1PHP &gt;=8.1

0.5.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/229567?v=4)[Matthias Burtscher](/maintainers/mburtscher)[@mburtscher](https://github.com/mburtscher)

![](https://avatars.githubusercontent.com/u/338856?v=4)[David Roth](/maintainers/davidroth)[@davidroth](https://github.com/davidroth)

![](https://avatars.githubusercontent.com/u/3588470?v=4)[Arjan Frans](/maintainers/arjanfrans)[@arjanfrans](https://github.com/arjanfrans)

![](https://avatars.githubusercontent.com/u/1465587?v=4)[Michael Zangerle](/maintainers/michaelzangerle)[@michaelzangerle](https://github.com/michaelzangerle)

![](https://www.gravatar.com/avatar/a4d72428e6647bf401af2690325b8e05b293ac6c7844babf800b42a86c0a9ce7?d=identicon)[DominicLuidold](/maintainers/DominicLuidold)

---

Top Contributors

[![arjanfrans](https://avatars.githubusercontent.com/u/3588470?v=4)](https://github.com/arjanfrans "arjanfrans (9 commits)")[![DominicLuidold](https://avatars.githubusercontent.com/u/22751730?v=4)](https://github.com/DominicLuidold "DominicLuidold (7 commits)")[![janikfu](https://avatars.githubusercontent.com/u/160492061?v=4)](https://github.com/janikfu "janikfu (4 commits)")[![mburtscher](https://avatars.githubusercontent.com/u/229567?v=4)](https://github.com/mburtscher "mburtscher (3 commits)")[![michaelzangerle](https://avatars.githubusercontent.com/u/1465587?v=4)](https://github.com/michaelzangerle "michaelzangerle (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k455.6M9.6k](/packages/symfony-dependency-injection)[symfony/config

Helps you find, load, combine, autofill and validate configuration values of any kind

4.3k479.6M8.4k](/packages/symfony-config)[symfony/service-contracts

Generic abstractions related to writing services

2.6k914.7M605](/packages/symfony-service-contracts)[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k525.7M2.0k](/packages/symfony-options-resolver)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M387](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

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