PHPackages                             tourze/async-import-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. tourze/async-import-bundle

ActiveSymfony-bundle

tourze/async-import-bundle
==========================

Symfony异步导入模块

0.1.2(6mo ago)022MITPHPCI passing

Since Apr 12Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/tourze/async-import-bundle)[ Packagist](https://packagist.org/packages/tourze/async-import-bundle)[ RSS](/packages/tourze-async-import-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (44)Versions (7)Used By (0)

AsyncImportBundle
=================

[](#asyncimportbundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/3f74bfc15618f25e0fcdf314f15b8c0bd20e9fa0e632cbfe0aff2be5a0605618/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f6173796e632d696d706f72742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/async-import-bundle)[![PHP Version](https://camo.githubusercontent.com/289c3921c35ea1586781ad48dd66d071b38c4ea648c065e3fbab8d41b47553f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f6173796e632d696d706f72742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/async-import-bundle)[![License](https://camo.githubusercontent.com/c047a9179b1561de0c84864c2857606d37f0cacf72c27c667d0a24af1dd96de0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f6173796e632d696d706f72742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/async-import-bundle)[![Code Coverage](https://camo.githubusercontent.com/ed693db583bb294cb97ecf96310970f07751a48e017052448eeb3c5c74e56445/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f6173796e632d696d706f72742d62756e646c653f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/async-import-bundle)

A powerful Symfony bundle for handling asynchronous file imports with support for CSV, Excel, and JSON formats. Features include progress tracking, error logging, retry mechanisms, and batch processing.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Advanced Usage](#advanced-usage)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **Multiple File Formats**: Support for CSV, Excel (XLS/XLSX), and JSON files
- **Asynchronous Processing**: Uses Symfony Messenger for background processing
- **Progress Tracking**: Real-time progress updates with speed calculation
- **Error Handling**: Detailed error logging with line numbers and data
- **Retry Mechanism**: Automatic retry with exponential backoff
- **Batch Processing**: Configurable batch sizes for memory efficiency
- **Extensible Architecture**: Easy to add custom import handlers
- **EasyAdmin Integration**: Ready for admin panel integration

Dependencies
------------

[](#dependencies)

### System Requirements

[](#system-requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher

### Required Extensions

[](#required-extensions)

- ext-SPL
- ext-date
- ext-json

### Required Packages

[](#required-packages)

- doctrine/dbal ^4.0
- doctrine/orm ^3.0
- phpoffice/phpspreadsheet ^3.9
- symfony/messenger ^6.4
- And other Symfony components (see composer.json for complete list)

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

[](#installation)

```
composer require tourze/async-import-bundle
```

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

[](#configuration)

### 1. Register the bundle

[](#1-register-the-bundle)

Register the bundle in your `config/bundles.php`:

```
return [
    // ...
    AsyncImportBundle\AsyncImportBundle::class => ['all' => true],
    // ...
];
```

### 2. Configure Messenger

[](#2-configure-messenger)

Add to `config/packages/messenger.yaml`:

```
framework:
    messenger:
        transports:
            async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                options:
                    queue_name: import
                retry_strategy:
                    max_retries: 3
                    delay: 1000
                    multiplier: 2

        routing:
            AsyncImportBundle\Message\ProcessImportTaskMessage: async
            AsyncImportBundle\Message\ProcessImportBatchMessage: async
            AsyncImportBundle\Message\CleanupImportTaskMessage: async
```

### 3. Create upload directory

[](#3-create-upload-directory)

```
mkdir -p var/import
chmod 755 var/import
```

Usage
-----

[](#usage)

### 1. Create an Import Handler

[](#1-create-an-import-handler)

```
