PHPackages                             hugoseigle/symfony-import-export-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. hugoseigle/symfony-import-export-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

hugoseigle/symfony-import-export-bundle
=======================================

Symfony bundle for importing and exporting entities

v1.0.2(1y ago)49MITPHPPHP &gt;=8.3

Since Oct 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/HugoSEIGLE/symfony-import-export-bundle)[ Packagist](https://packagist.org/packages/hugoseigle/symfony-import-export-bundle)[ RSS](/packages/hugoseigle-symfony-import-export-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (11)Versions (4)Used By (0)

[![Packagist Version](https://camo.githubusercontent.com/4d501693a2ae05d0534c5383e943a056fb08245814c9391d62ccd8cf733b5249/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6875676f736569676c652f73796d666f6e792d696d706f72742d6578706f72742d62756e646c65)](https://camo.githubusercontent.com/4d501693a2ae05d0534c5383e943a056fb08245814c9391d62ccd8cf733b5249/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6875676f736569676c652f73796d666f6e792d696d706f72742d6578706f72742d62756e646c65)[![Total Downloads](https://camo.githubusercontent.com/336bb7592f98a4a3904fbf2a103edc2364ba369dd47151cd09c245e144858765/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6875676f736569676c652f73796d666f6e792d696d706f72742d6578706f72742d62756e646c65)](https://camo.githubusercontent.com/336bb7592f98a4a3904fbf2a103edc2364ba369dd47151cd09c245e144858765/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6875676f736569676c652f73796d666f6e792d696d706f72742d6578706f72742d62756e646c65)

📦 Symfony ImportExportBundle
============================

[](#-symfony-importexportbundle)

The SymfonyImportExportBundle simplifies data import, export, and template generation in Symfony applications. By leveraging Doctrine entities and Symfony forms, this bundle provides a seamless data management workflow.

🚀 Installation
--------------

[](#-installation)

### Install the bundle via Composer:

[](#install-the-bundle-via-composer)

```
composer require hugoseigle/symfony-import-export-bundle
```

### Register the bundle in config/bundles.php:

[](#register-the-bundle-in-configbundlesphp)

```
SymfonyImportExportBundle\SymfonyImportExportBundle::class => ['all' => true],
```

⚙️ Configuration
----------------

[](#️-configuration)

### Set up import\_export.yaml in config/packages:

[](#set-up-import_exportyaml-in-configpackages)

```
import_export:
  date_format: 'Y-m-d'
  bool_true: 'true'
  bool_false: 'false'
  importers:
    App\Entity\Product:
      fields:
        - name
        - description
        - price
        - active
        - createdAt
        - updatedAt
      allow_delete: true
      unique_fields: ['name']
```

### Configuration Options

[](#configuration-options)

```
    date_format: Format used for dates in import/export operations.
    bool_true / bool_false: Values for boolean true and false to ensure compatibility with different data sources.
    importers: Configure entity fields for import:
        fields: Define the fields to import.
        allow_delete: Enable or disable deletion of existing records.
        unique_fields: Specify unique fields for identifying existing entities.
```

📄 Usage
-------

[](#-usage)

### ✨ Exporter

[](#-exporter)

The Exporter allows exporting data from entities into CSV or XLSX files.

#### Basic Export Usage

[](#basic-export-usage)

```
use SymfonyImportExportBundle\Services\Export\ExporterInterface;

// Inject the ExporterInterface
public function exportData(ExporterInterface $exporter): Response
{
    $query = $this->productRepository->yourQueryMethod();

    return $exporter->exportCsv($query, ['getName', 'getDescription', ...], 'fileName', ExporterInterface::XLSX); // or 'csv'
}
```

### ✨ Importer

[](#-importer)

The Importer allows importing data from CSV or XLSX files into entities, with validation handled by Symfony Forms.

#### Setting Up the Import Form

[](#setting-up-the-import-form)

```
Note: For boolean fields, set empty_data to false or true explicitly in the form type to ensure values are not interpreted as null.

```

```
// src/Form/ProductType.php

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;

class ProductType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name')
            ->add('description')
            ->add('price')
            ->add('active', CheckboxType::class, [
                'required' => false,
                'empty_data' => 'false', // Ensures boolean fields are handled correctly
            ]);
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Product::class,
        ]);
    }
}
```

#### Importing Data

[](#importing-data)

```
use SymfonyImportExportBundle\Services\Import\ImporterInterface;

// Inject the ImporterInterface
public function importData(Request $request, ImporterInterface $importer): Response
{
    $file = $request->files->get('import_file'); // Retrieve file from the form or request
    $importer->import($file, Product::class, ProductType::class);

    if ($importer->isValid()) {
        $summary = $importer->getSummary();

        foreach ($summary['created'] as $created) {
            $this->entityManager->persist($created);
        }

        foreach ($summary['updated'] as $updated) {
            $this->entityManager->persist($updated);
        }

        foreach ($summary['deleted'] as $deleted) {
            $deleted->delete();
        }

        $this->entityManager->flush();

        return new Response("Import successful! {$summary['inserted']} inserted, {$summary['updated']} updated.");
    } else {
        $errors = $importer->getErrors();
        return new Response("Import failed with errors: " . implode(', ', $errors));
    }
}
```

### ✨ Import Template Generator

[](#-import-template-generator)

The Import Template Generator creates CSV or XLSX templates with headers based on configured fields, allowing users to download pre-formatted templates. Generating an Import Template

```
use SymfonyImportExportBundle\Services\Import\ImporterTemplateInterface;

// Inject the ImporterTemplateInterface
public function generateImportTemplate(ImporterTemplateInterface $templateGenerator): Response
{
    return $templateGenerator->getImportTemplate(Product::class, ImporterInterface::XLSX); // or 'csv'
}
```

🔧 Advanced Usage
----------------

[](#-advanced-usage)

### Customizing Field Translations

[](#customizing-field-translations)

To translate field names, add them to your translations/messages.yaml file:

```
import_export:
  name: "Product Name"
  description: "Product Description"
  price: "Price"
  active: "Available"
```

### Error Handling and Custom Translations

[](#error-handling-and-custom-translations)

Each validation error and import/export error can be translated. For example:

```
import_export:
  missing_field: "Missing field: {{ field }}"
  invalid_boolean: "Invalid boolean value for: {{ field }}"
  invalid_datetime: "Invalid date format for: {{ field }}"
  invalid_headers: "The headers in the file do not match the expected format."
```

🛠 FAQ

Q: How do I customize date formats for imports? A: Adjust the date\_format option in import\_export.yaml.

Q: How are boolean values handled during import? A: Ensure the bool\_true and bool\_false values are configured in import\_export.yaml to match data inputs. Set empty\_data on boolean fields in the form.

Q: Can I specify unique fields for updating records? A: Yes, add unique\_fields in the configuration to identify existing records.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance43

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Total

3

Last Release

453d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.1

v1.0.1PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e485017438ce210fcf7de14df07feb1219b5a0e2de33a742586944c2f5ab86b?d=identicon)[HugoSEIGLE](/maintainers/HugoSEIGLE)

---

Top Contributors

[![HugoSEIGLE](https://avatars.githubusercontent.com/u/102899493?v=4)](https://github.com/HugoSEIGLE "HugoSEIGLE (18 commits)")

---

Tags

bundlecsvdoctrineexportimportsymfonyxlsx

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hugoseigle-symfony-import-export-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/hugoseigle-symfony-import-export-bundle/health.svg)](https://phpackages.com/packages/hugoseigle-symfony-import-export-bundle)
```

###  Alternatives

[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[lexik/translation-bundle

This bundle allows to import translation files content into the database and provide a GUI to edit translations.

4362.7M19](/packages/lexik-translation-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
