PHP code example of jdz / importer

1. Go to this page and download the library: Download jdz/importer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jdz / importer example snippets


use JDZ\Importer\Importer;

$rows = (new Importer())->parse('/tmp/upload.xlsx');
// [ ['name' => 'Doe', 'email' => '[email protected]'], … ]

class MembersImporter extends Importer
{
    protected function getColumns(): array
    {
        return [
            (object)['field' => 'name'],
            (object)['field' => 'active',  'type' => 'bool',  'default' => 0],
            (object)['field' => 'website', 'type' => 'url'],
            (object)['field' => 'joined',  'type' => 'date'],
        ];
    }
}