1. Go to this page and download the library: Download glueful/import-export 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/ */
glueful / import-export example snippets
public static function services(): array
{
return [
// Plain-string tag form
App\Imports\ProductsImporter::class => [
'class' => App\Imports\ProductsImporter::class,
'shared' => true,
'autowire' => true,
'tags' => ['import_export.importer'],
],
// Object tag form with priority
App\Exports\ProductsExporter::class => [
'class' => App\Exports\ProductsExporter::class,
'shared' => true,
'autowire' => true,
'tags' => [
['name' => 'import_export.exporter', 'priority' => 10],
],
],
];
}
use Glueful\Extensions\ImportExport\Services\ImportExportService;
use Glueful\Extensions\ImportExport\Support\ImportOptions;
use Glueful\Extensions\ImportExport\Support\ImportSource;
$job = $imports->createImport(
'products',
new ImportSource('uploads', 'imports/products.csv', 'text/csv'),
new ImportOptions(mode: 'dry_run', batchSize: 500, actorUuid: $userUuid)
);