Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Import Export Bundle Laravel Package

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...

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. Register Sylius\Bundle\ImportExportBundle\SyliusImportExportBundle in config/bundles.php (usually already present via sylius/sylius).
  2. Define which resources are importable/exportable under sylius_import_export.resources in config/packages/_sylius.yaml — each entry maps a resource name to a class and a list of formats.
  3. Confirm the console commands are available: bin/console sylius:import <resource> <file> <format> and bin/console sylius:export <resource> <file> <format>.
  4. Export a small fixture, inspect the header row, then re-import it unchanged. That round trip is your first use case and your fastest sanity check.

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.
  • Sylius core's own importer service definitions (e.g., product importer) as reference implementations; they're the most realistic examples you'll find.

Implementation Patterns

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.

Gotchas and Tips

  • Ecosystem mismatch is the first gotcha. No Laravel service provider, no config publish, and the Symfony/Doctrine dependencies will conflict with a typical Laravel app. Don't try to install it into Laravel — read it, don't require it.
  • Headers are the contract. Column names map directly to field names on the importer. A renamed header is a silently dropped field, not an exception. Pin the header in tests.
  • Encoding bites. UTF-8 BOM from Excel breaks the first header cell and thus the first column mapping. Strip BOM, enforce UTF-8, and document the delimiter explicitly — the default may not be what your spreadsheet emits.
  • Relations need identifiers, not IDs. Product taxons, channels, and options are resolved by code, not by primary key. Import order matters: reference data (taxons, options, shipping categories) must exist before products.
  • Locale and channel context. Translatable fields and channel-priced values require the importer to know which locale/channel it's writing into. Missing this produces rows that look imported but render empty in the storefront.
  • No transactional safety by default. A mid-file failure leaves partial data. Run imports against a snapshot, or wrap your own importer in a transaction per batch so you can resume from a known row.
  • Error messages are thin. Most failures surface as a generic exception with the row array attached. Log the row index alongside the payload in your importer so you can reproduce.
  • Config cache. After editing sylius_import_export.resources, clear the cache — the registry is built at container compile time and won't see new entries otherwise.
  • Export memory. Wide catalogs with many attributes blow up in-memory exports. Stream or chunk the export; don't ->findAll().
  • Debugging hook. The registry lookup is where "unknown importer" errors originate — check that the resource name and format string in your command exactly match the config keys, including case.
  • Extension points. The registry and the interfaces are the seams. Custom formats (JSON, XLSX) are added by registering a new importer/exporter pair, not by modifying the bundle.
  • License. Marked NOASSERTION — the repo's licensing is ambiguous from metadata alone. Verify before vendoring any code into a commercial Laravel app.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings