sylius/import-export-bundle
Sylius Import/Export Bundle adds configurable data import and export to Sylius applications. Import products, customers, orders, and other resources from CSV files and export them back, with extensible processors, importers, exporters, and console commands for automated catalog and store data manage...
First, calibrate your expectations: this is not a Laravel package. There is no service provider, no config/import_export.php, no auto-discovery, and composer require sylius/import-export-bundle will drag in Symfony, Doctrine, and the Sylius resource stack. It is a component of the Sylius monorepo (the low star count and zero dependents reflect that it's consumed via sylius/sylius, not standalone). So "day-to-day leverage" splits into two tracks: (a) using it inside a Sylius/Symfony app, and (b) porting its architecture into a Laravel app.
Minimal steps inside Sylius/Symfony:
Sylius\Bundle\ImportExportBundle\SyliusImportExportBundle in config/bundles.php (usually already present via sylius/sylius).sylius_import_export.resources in config/packages/_sylius.yaml — each entry maps a resource name to a class and a list of formats.bin/console sylius:import <resource> <file> <format> and bin/console sylius:export <resource> <file> <format>.Where to look first, in order:
Console/Command/ImportCommand.php and ExportCommand.php — the real entry points and the options you'll actually pass.Importer/ImporterInterface.php and Exporter/ExporterInterface.php — the two contracts you'll implement.Importer/ImporterRegistry.php / ExporterRegistry.php — how resource + format resolves to a concrete service.DependencyInjection/Configuration.php — the exact shape of the resources config tree.CLI round trip as the primary workflow. Export a resource to CSV, hand it to ops/content, re-import the edited file. This is the package's happy path and the reason it exists. Keep exported files under version control or timestamped so a bad import can be replayed.
Custom importer service per resource. Implement ImporterInterface::import(array $data) and tag the service (sylius.importer with a type/format attribute, per the bundle's DI conventions). Keep the class thin: validate the row array, resolve relations by code, delegate persistence. Register it in the same config block as the resource.
Extend the base importer rather than starting from scratch. The shipped base importer already handles the registry lookup, header-to-field mapping, and per-row iteration. Override the field mapping and relation resolution, not the loop.
Registry-based dispatch. Treat ImporterRegistry/ExporterRegistry as your strategy locator: resolve by resource name + format, then call the interface. In Laravel this translates almost one-to-one — bind a ImportRegistry singleton in a service provider, register drivers by key, and expose an ImportManager::driver('products', 'csv') facade method.
Batch + clear pattern. For anything beyond a few thousand rows, process in chunks and clear the Doctrine entity manager between chunks ($em->clear()), re-fetching any referenced entities. Without this you'll hit memory ceilings and stale-identity bugs on the second chunk.
Queue it behind a job. The commands are synchronous and unbounded. In Sylius, wrap the command invocation in a Symfony message handler; in Laravel, an ImportProductsJob that either shells out to the command or (if you ported the code) calls your importer service directly with ShouldQueue, retries, and a stored result summary.
Validate before persisting, per row. Collect row-level errors rather than throwing on the first bad line. A 5,000-row file with one malformed price should report the line number and continue, not abort silently at row 12.
Port pattern for Laravel. ImporterInterface → App\Imports\Contracts\Importer; registry → container-tagged importers with a manager; console commands → php artisan import:products {file}; CSV reading → league/csv with a header mapper. The bundle's value to you is the shape, not the code.
code, not by primary key. Import order matters: reference data (taxons, options, shipping categories) must exist before products.sylius_import_export.resources, clear the cache — the registry is built at container compile time and won't see new entries otherwise.->findAll().NOASSERTION — the repo's licensing is ambiguous from metadata alone. Verify before vendoring any code into a commercial Laravel app.How can I help you explore Laravel packages today?