dmytrof / import-bundle
Symfony Bundle to import data
Requires
- php: ^8.4
- ext-dom: *
- ext-json: *
- ext-simplexml: *
- dmytrof/models-management-bundle: ^1.12
- doctrine/collections: ^2.2 || ^3.0
- doctrine/doctrine-bundle: ^2.13 || ^3.0
- doctrine/inflector: ^2.0
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4.0
- gedmo/doctrine-extensions: ^3.16
- guzzlehttp/guzzle: ^7.0
- laminas/laminas-feed: ^2.22
- laminas/laminas-json: ^3.6
- laminas/laminas-xml2json: ^3.3
- monolog/monolog: ^2.9 || ^3.0
- psr/http-message: ^1.1 || ^2.0
- psr/log: ^2.0 || ^3.0
- symfony/config: ^6.4 || ^7.0 || ^8.0
- symfony/console: ^6.4 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.0 || ^8.0
- symfony/doctrine-bridge: ^6.4 || ^7.0 || ^8.0
- symfony/event-dispatcher: ^6.4 || ^7.0 || ^8.0
- symfony/event-dispatcher-contracts: ^3.0
- symfony/filesystem: ^6.4 || ^7.0 || ^8.0
- symfony/form: ^6.4 || ^7.0 || ^8.0
- symfony/http-client: ^6.4 || ^7.0 || ^8.0
- symfony/http-foundation: ^6.4 || ^7.0 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.0 || ^8.0
- symfony/lock: ^6.4 || ^7.0 || ^8.0
- symfony/monolog-bundle: ^3.10 || ^4.0
- symfony/options-resolver: ^6.4 || ^7.0 || ^8.0
- symfony/routing: ^6.4 || ^7.0 || ^8.0
- symfony/translation: ^6.4 || ^7.0 || ^8.0
- symfony/translation-contracts: ^3.0
- symfony/validator: ^6.4 || ^7.0 || ^8.0
- symfony/yaml: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- ext-pdo_sqlite: *
- phpunit/phpunit: ^11.5
- symfony/framework-bundle: ^6.4 || ^7.0 || ^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-29 20:26:57 UTC
README
This bundle helps you to import data (JSON, XML, RSS, CSV) into your Symfony application.
Requirements
- PHP 8.4 or higher
- Symfony 6.4, 7.x or 8.x
- Doctrine ORM 3 with DoctrineBundle 2.13+ or 3.x
- dmytrof/models-management-bundle 1.12+
Installation
Step 1: Install the bundle
$ composer require dmytrof/import-bundle
Step 2: Enable the bundle
<?php
// config/bundles.php
return [
// ...
Dmytrof\ModelsManagementBundle\DmytrofModelsManagementBundle::class => ['all' => true],
Dmytrof\ImportBundle\DmytrofImportBundle::class => ['all' => true],
];
Step 3: Register the entities mapping
The bundle entities (Task, Item) are mapped with PHP attributes:
# config/packages/doctrine.yaml
doctrine:
orm:
mappings:
DmytrofImportBundle:
is_bundle: false
type: attribute
dir: '%kernel.project_dir%/vendor/dmytrof/import-bundle/src/Entity'
prefix: 'Dmytrof\ImportBundle\Entity'
alias: DmytrofImport
Then create the tables with Doctrine migrations:
$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
The Task entity uses Gedmo Blameable and Timestampable traits, so make sure
the Gedmo BlameableListener and TimestampableListener are registered
(for example via stof/doctrine-extensions-bundle or DmytrofModelsManagementBundle).
Usage
Import scheduled tasks:
$ php bin/console dmytrof:import:tasks
Import scheduled items:
$ php bin/console dmytrof:import:items --all
Upgrading from 1.x (Symfony 4/5)
- Doctrine mapping switched from annotations to PHP attributes: set
type: attributefor the bundle mapping (see Step 3). - Validation constraints switched from annotations to PHP attributes.
- The Doctrine listener is now registered with the
doctrine.event_listenertag instead of the deprecateddoctrine.event_subscribertag. - Custom form types, data transformers, readers and importers extending the bundle
classes must use return types compatible with Symfony 6.4
(e.g.
configureOptions(): void,getParent(): ?string,transform(mixed $value): mixed).
Upgrading to PHP 8.4 / Doctrine ORM 3
-
EntityManager::merge()(removed in ORM 3) is no longer used: after an import the task (and an item failed to import) is re-fetched from the entity manager when the importer has detached it.PostImportTaskEventreceives the managed task. -
Entity\Task\Task::$activeis typedboolandEntity\Item\Item::$targetis typed?array(as in ModelsManagementBundle 1.12 traits): redeclare them with the same types in your subclasses. -
ImportableFields::set(),ImportableFieldsOptions::set()andadd()follow Doctrine Collections 2/3 signatures (set(string|int $key, mixed $value): void): they are not fluent anymore. -
Services use
!tagged_iterator(the!taggedYAML tag was removed in Symfony 8). -
symfony/translationis required (readers and importers use the translator). -
On PHP 8.4 with DoctrineBundle 2.x enable native lazy objects:
# config/packages/doctrine.yaml doctrine: orm: enable_native_lazy_objects: true