Manage your csv with this bundle.
- Download CsvBundle
- Enable the bundle
Modify your composer.json on your project root
// {root}/composer.json
{
[...],
"require": {
[...],
"imag/csv-bundle": "dev-master"
}
}
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new IMAG\CsvBundle\IMAGCsvBundle(),
);
}
<?php
// Init the manager
$manager = $this->get('imag_csv.manager.csv');
$manager
->setFilename('/tmp/test.csv')
->setDelimiter(',')
->setEnclosure('"')
;
// Create a row on Csv
$row = $manager->createRow();
$row
->addField('1')
->addField('2')
;
$manager->addRow($row);
// Write Csv
$manager->write();