Download the PHP package kaliop/csv-parser without Composer
On this page you can find all versions of the php package kaliop/csv-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kaliop/csv-parser
More information about kaliop/csv-parser
Files in kaliop/csv-parser
Package csv-parser
Short Description PHP/OOP CSV Parser
License MIT
Homepage https://tech.kaliop.com
Informations about the package csv-parser
CSV Parser Library
This library allows you to define your CSV parsing in OOP style, allowing you to easily filter and test your imports. It's been in production on various large clients with multiples complex imports for quite some time now.
Main advantages are:
- OOP-style: One Parser class per import = meaningful for developers working on the project.
- Testable: A fixture csv and you can easily write tests for the import.
- Fully Customizable: each parsed result is also a PHP class where the developer can add its own logic.
- Lightly coupled: this package depends only on Symfony's Validator. Any database/persistence stuff is possible (see example below).
Installation
Install this package using composer:
Basic Usage
You'll need to describe the mapping between CSV columns and entity's properties. To do so, you should start by creating a Parser, but first, let's take a look at our CSV:
our Entity looks like this:
Creating the Parser:
And now do the magic! In this example we persist imported entities in database.
Advanced Usage
You can decide to change the default class to do you own logic once the Entity has been parsed. In the following example we will add a which will be set by our custom result class, in the method:
Now just tell your Parser to use this Result class and you're ready: