Zend Framework 2 module to export and import CSV files

Installs: 8 973

Dependents: 2

Stars: 13

Watchers: 4

Forks: 14

Open Issues: 2

v1.1.0 2014-04-19 05:22 UTC


The RdnCsv ZF2 module makes it really easy to export and import CSV files.

How to install

  1. Use composer to require the radnan/rdn-csv package:

    $ composer require radnan/rdn-csv:1.*
  2. Activate the module by including it in your application.config.php file:

    return array(
       'modules' => array(
           // ...

How to use

The module comes with two plugins - csvExport() and csvImport().


Export data into a downloadable CSV file using this plugin.

// inside a controller action

$header = array(
$records = array(
        'ac, abs, moon',

return $this->csvExport('foo.csv', $header, $records);

The plugin will return a response object which you can then return from your controller action.

Read more documentation on csvExport()


Import data from a CSV file using this plugin.

// inside a controller action

$csv = $this->csvImport('/path/to/foo.csv');

foreach ($csv as $row)
    // array(
    //     'Year' => '1997',
    //     'Make' => 'Ford',
    //     'Model' => 'E350',
    //     'Description' => 'ac, abs, moon',
    //     'Price' => '3000.00',
    // )

The plugin returns an iterator that can be used to loop over all the rows in the CSV file.

Read more documentation on csvImport()