Download the PHP package heimrichhannot/contao-entity-import-bundle without Composer

On this page you can find all versions of the php package heimrichhannot/contao-entity-import-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package contao-entity-import-bundle

Contao Entity Import Bundle

This bundle offers a generic importer to migrate data from various sources to contao database entities.

This Bundle is still in development.

Features

Impressions

Importer source backend settings:

Importer config backend settings:

Installation

Install via composer: composer require heimrichhannot/contao-entity-import-bundle and update your database.

Configuration

  1. Navigate to "Import" in the Contao backend in the section "system".
  2. Create an importer source to your needs.
  3. Create an importer using the source created in the step before.
  4. Run the importer either using dry-run or the normal mode.

config.yml

Technical instructions

Output messages during import process respecting the context

An importer can be run as command, cronjob or in the web context. The context implies how to output messages (or error messages).

For example, when running an importer by clicking the "import" button in the website (i.e. in the browser), the messages should be printed out using \Contao\Message::addError() (or addConfirmation(), ...). If the import is run as command, the same messages need to be printed out on command line using a SymfonyStyle instance. If the command is also run in web context, the messages even need to be stored to the tl_entity_import_config entity, because these are retrieved by ajax in the progress bar view.

As you can see, it's not just "printing a message", but taking care of the context, as well.

For this you can use the method ImporterInterface::outputResultMessage() which takes care of the correct context itself.

Run as symfony command

huh:entity-import:execute config-ids [--dry-run]

where config-ids needs to be a comma separated list of importer config IDs.

Arguments
Argument Mandatory Type Description
config-id true integer The ID of the importer configuration
dry-run false boolean Run importer without writing data into database

Run as contao cron

Import is executable with contao poor man's cron. The interval of execution is similar to the contao definition. The import configuration allows to enable cron execution and picking of the cron interval. Possible to choose between minutely, hourly, daily, weekly, monthly interval. It is recommended to setup the debug options in config.yml before importing via cronjob.

Add custom sources

  1. Create the source and extend from \HeimrichHannot\EntityImportBundle\Source\AbstractSource or implement the interface \HeimrichHannot\EntityImportBundle\Source\SourceInterface.
  2. Create an event listener for the event SourceFactoryCreateSourceEvent:

  3. Create a tl_entity_import_source.php and add your sources in the type field's options:

  4. Create your palette in your tl_entity_import_source.php, e.g. by copying one from this bundle.

Add presets for source/config field mapping

Adding a field mapping might be tedious sometimes. Hence we provide an event for adding presets which then are selectable in the backend entity (source and config).

Just register an event listener and add your presets the following way:

Add quick importers for editors

To be honest: A "quick importer" is a nicer term for "easy importer", so that editors don't get sad ;-) The use case for quick importers is to have a user interface which is way easier to use for editors.

Simply create an import source and import config as you would normally. Afterwards editors can create quick importers on their own and add custom file sources (currently only files of the type CSV are supported).

Run the import via cronjob in web context

If you have large datasets the import might take too much memory of the web server. In this case it's often useful to

  1. Run the importer as symfony command. This has to be done by a developer.
  2. Run the importer in the web context by cronjob. This can be done by editors or developers.

In most cases, running an importer by command on the shell takes way less memory compared to running it in the web context via website.

For option 2 to work you need to do the following steps:

  1. Add the bundle's import command as cronjob using the parameter --web-cron-mode:
    * * * * * /path/to/vendor/bin/contao-console huh:entity-import:execute <import config ids> --web-cron-mode >/dev/null 2>&1
  2. Activate useCron in the importer config and fill out the needed fields.
  3. Activate useCronInWebContext in the importer config.

Events

Name Description
AddConfigFieldMappingPresetsEvent Add config field mapping presets
AddSourceFieldMappingPresetsEvent Add source field mapping presets
AfterCsvFileSourceGetRowEvent Modify csv rows e.g. for fixing file encoding issues
AfterFileSourceGetContentEvent Configure the data after receiving from source
AfterImportEvent Get imported data after finished import
AfterItemImportEvent Get imported item data after finished import
BeforeAuthenticationEvent Configure authentication data before sending GET request to http source
BeforeImportEvent Configure the data before importing
BeforeItemImportEvent Configure the item data before importing; call setSkipped(true) in order to skip the import
SourceFactoryCreateSourceEvent Implement custom logic for new custom file sources
BeforeFileImportEvent Implement a custom logic for setting the folder and/or file path when importing files

All versions of contao-entity-import-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4||^8.0
ausi/slug-generator Version ^1.1
contao/core-bundle Version ^4.9
guzzlehttp/guzzle Version ^6.0 || ^7.0
heimrichhannot/contao-be_explanation-bundle Version ^2.3
heimrichhannot/contao-field-value-copier-bundle Version ^1.1
heimrichhannot/contao-list_widget Version ^2.1
heimrichhannot/contao-multi-column-editor-bundle Version ^2.4
heimrichhannot/contao-progress-bar-widget-bundle Version ^0.1
heimrichhannot/contao-utils-bundle Version ^2.135
symfony/cache Version ^4.4 || ^5.2
symfony/config Version ^4.4||^5.4
symfony/console Version ^4.4||^5.4
symfony/dependency-injection Version ^4.4||^5.4
symfony/event-dispatcher Version ^4.4||^5.4
symfony/event-dispatcher-contracts Version ^1||^2||^3
symfony/http-kernel Version ^4.4||^5.4
symfony/stopwatch Version ^4.4 || ^5.2
terminal42/service-annotation-bundle Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package heimrichhannot/contao-entity-import-bundle contains the following files

Loading the files please wait ....