PHPackages                             avtonom/mathielen-import-engine-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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. avtonom/mathielen-import-engine-bundle

ActiveSymfony-bundle[PDF &amp; Document Generation](/categories/documents)

avtonom/mathielen-import-engine-bundle
======================================

A generic import (and export) -engine that provides easy to use yet powerful features

0.5(10y ago)2258MITPHPPHP &gt;=5.4.0

Since Aug 25Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Avtonom/ImportEngineBundle)[ Packagist](https://packagist.org/packages/avtonom/mathielen-import-engine-bundle)[ Docs](https://github.com/mathielen/ImportEngineBundle)[ RSS](/packages/avtonom-mathielen-import-engine-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (14)Used By (0)

Mathielen Import Engine Bundle
==============================

[](#mathielen-import-engine-bundle)

[![Build Status](https://camo.githubusercontent.com/2ab4c798626aa6e80aab1b85f3502f6e70be7e843d0e97bb139bb3d249a9cd9e/68747470733a2f2f7472617669732d63692e6f72672f6d61746869656c656e2f496d706f7274456e67696e6542756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mathielen/ImportEngineBundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/66436d8e214a4348b01db4e27456de40c19ae1e25293eed62d1de3556c76dfa7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d61746869656c656e2f496d706f7274456e67696e6542756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mathielen/ImportEngineBundle/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/92411407f3b1d772fcc54dd2c5e3b572f7486b731d494410e5e150f274c75b8a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d61746869656c656e2f496d706f7274456e67696e6542756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mathielen/ImportEngineBundle/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/b9181910ffd527d88e62796e087dc113f39544deeb3cb53ad31649c4b883619b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31366632616630652d393331382d343766372d626431322d6433663037636166316432312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/16f2af0e-9318-47f7-bd12-d3f07caf1d21)[![Latest Stable Version](https://camo.githubusercontent.com/2ea9b033f22a7cd265bc1e0136471934f68e4a859b859ea6f56e07c549ccbd89/68747470733a2f2f706f7365722e707567782e6f72672f6d61746869656c656e2f696d706f72742d656e67696e652d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/mathielen/import-engine-bundle)

Introduction
------------

[](#introduction)

This is a bundle for the [mathielen/import-engine library](https://github.com/mathielen/import-engine). It provides an easy way to configure a full-blown data importer for your symfony2 project.

Installation
------------

[](#installation)

This library is available on [Packagist](https://packagist.org/packages/mathielen/import-engine-bundle):

To install it, run:

```
$ composer require mathielen/import-engine-bundle
```

Then add the bundle to `app/AppKernel.php`:

```
public function registerBundles()
{
    return array(
        ...
        new Mathielen\ImportEngineBundle\MathielenImportEngineBundle(),
        ...
    );
}
```

Configuration
-------------

[](#configuration)

Add your importer configurations in your `app/config/config.yml`.

Full example:

```
mathielen_import_engine:
    #configure storageproviders, that are used in all importers
    storageprovider:
        default:
            type: directory
            uri: /tmp/somedir
        upload:
            type: upload
            uri: "%kernel.root_dir%/Resources/import"
        doctrine:
            type: doctrine
            queries:        #a list of DQL-Statements, Entity-Classnames, filenames or directories
                - SELECT id FROM Acme\DemoBundle\Entity\Person P WHERE P.age > 10   #dql statement
                - Acme\DemoBundle\Entity\ImportData     #entity classname
                - %kernel.root_dir%/dql/mysql.dql       #file with dql statement in it
                - %kernel.root_dir%/other-dql           #directory
        dbal:
            type: dbal
            queries: %kernel.root_dir%/sql/         #same like doctrine
        services:
            type: service
            services:
                #the services export_serviceA and export_serviceB must be configured in DIC
                export_serviceA: [exportMethod1, exportMethod2] #restrict to specific methods of service
                export_serviceB: ~ #every method of service can be used

    #configure your Importers
    importers:
        your_importer_name:
            #some context information that is passed through the whole process
            context:
                key: value

            #automaticly recognize this importer by meeting of the conditions below
            preconditions:
                format: excel               #format of data must be [csv, excel, xml]
                fieldcount: 2               #must have this number of fields
                fields:                     #these fields must exist (order is irrelevant)
                    - 'header2'
                    - 'header1'
                fieldset:                   #all fields must exist exactly this order
                    - 'header1'
                    - 'header2'
                filename: 'somefile.xls'    #filename must match one of these regular expression(s) (can be a list)

            #use an object-factory to convert raw row-arrays to target objects
            object_factory:
                type: jms_serializer        #[jms_serializer, default]
                class: Acme\DemoBundle\ValueObject\MyImportedRow

            #add mapping
            mappings:
                #simple a-to-b mapping
                source-field1: target-field1

                #convert the field (but dont map)
                source-field2:
                    #converts excel's date-field to a Y-m-d string (you can use your own service-id here)
                    converter: mathielen_importengine.converter.excel.genericdate

                #map and convert
                source-field3:
                    to: target-field3
                    converter: upperCase    #use a converter that was registered with the converter-provider

            #validate imported data
            validation:
                source:                     #add constraints to source fields
                    header1: email
                    header2: notempty
                target: ~                   #activate validation against generated object from object-factory (via annotations, xml)
                                            #or supply list of constraints like in source

            #target of import
            target:
                type: service               #[service, doctrine, file]
                service: '@import_service'     #service name in DIC
                method: processImportRow    #method to invoke on service
```

Minimum example:

```
mathielen_import_engine:
    importers:
        minimum_importer:
            target:
                type: file
                uri: /tmp/myfile.csv
                format: csv

        another_minimum_importer:
            target:
                type: file
                uri: "@='%kernel.root_dir%/../output_'~date('Y-m-d')~'.csv'"    #this uses symfony expression language
                                                                                #to create the filename. Just prefix your
                                                                                #expression with @=
                format: { type: csv, arguments: [','] }                         #delimiter is now ','
```

Check out the Testsuite for more information.

Usage
-----

[](#usage)

### On the command line

[](#on-the-command-line)

#### Show your configured Import profiles

[](#show-your-configured-import-profiles)

```
$ app/console importengine:list
```

#### Let the framework discover which importer suites best (auto discovery)

[](#let-the-framework-discover-which-importer-suites-best-auto-discovery)

Uses the storageprovider "default" if not also given as argument.

```
$ app/console importengine:import /tmp/somedir/myfile.csv
```

#### Import myfile.csv with "your\_importer\_name" importer

[](#import-myfilecsv-with-your_importer_name-importer)

Uses the storageprovider "default" if not also given as argument.

```
$ app/console importengine:import -i your_importer_name /tmp/somedir/myfile.csv
```

#### Generate a [JMS Serializer](http://jmsyst.com/libs/serializer)-annotated ValueObject class for an arbitrary import source (ie. a file)

[](#generate-a-jms-serializer-annotated-valueobject-class-for-an-arbitrary-import-source-ie-a-file)

```
$ app/console importengine:generate:valueobject data/myfile.csv Acme\\ValueObject\\MyFileRow src
```

### Use the importer within a controller / service

[](#use-the-importer-within-a-controller--service)

```
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{

    /**
     * Import a given file, that was POST'ed to the HTTP-Endpoint /app/import
     * * Using the default sorage provider
     * * The importer is auto-discovered with the format of the file
     *
     * @Route("/app/import", name="homepage")
     * @Method("POST")
     */
    public function importAction(\Symfony\Component\HttpFoundation\Request $request)
    {
        //create the request for the import-engine
        $importRequest = new \Mathielen\ImportEngine\ValueObject\ImportRequest($request->files->getIterator()->current());

        /** @var \Mathielen\ImportEngine\Import\ImportBuilder $importBuilder */
        $importBuilder = $this->container->get('mathielen_importengine.import.builder');
        $import = $importBuilder->build($importRequest);

        /** @var \Mathielen\ImportEngine\Import\Run\ImportRunner $importRunner */
        $importRunner = $this->container->get('mathielen_importengine.import.runner');
        $importRun = $importRunner->run($import);

        return $this->render('default/import.html.twig', $importRun->getStatistics());
    }

}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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 ~58 days

Total

10

Last Release

3751d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/851a2d4f8d02604c04bd2c4331a901e4fc92ed7ec1371cbceafb48c2495efc8c?d=identicon)[avtonomspb](/maintainers/avtonomspb)

---

Top Contributors

[![mathielen](https://avatars.githubusercontent.com/u/1571485?v=4)](https://github.com/mathielen "mathielen (101 commits)")

---

Tags

csvimport

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/avtonom-mathielen-import-engine-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/avtonom-mathielen-import-engine-bundle/health.svg)](https://phpackages.com/packages/avtonom-mathielen-import-engine-bundle)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M711](/packages/maatwebsite-excel)[league/csv

CSV data manipulation made easy in PHP

3.5k166.1M645](/packages/league-csv)[goodby/csv

CSV import/export library

9555.6M23](/packages/goodby-csv)[ddeboer/data-import-bundle

A Symfony2 bundle for the ddeboer/data-import library

691.3M1](/packages/ddeboer-data-import-bundle)[handcraftedinthealps/goodby-csv

CSV import/export library

441.6M4](/packages/handcraftedinthealps-goodby-csv)[jgrygierek/batch-entity-import-bundle

Importing entities with preview and edit features for Symfony.

101.1M1](/packages/jgrygierek-batch-entity-import-bundle)

PHPackages © 2026

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