vinorcola/import-bundle
Composer 安装命令:
composer require vinorcola/import-bundle
包简介
Bundle providing tools for importing and mapping a file.
README 文档
README
A bundle to import data from CSV or Excel files, letting the user map the columns of its file to the required fields for your process.
Configuration
Setup a temporary directory in which the uploaded files will be stored temporarily.
Setup as many imports as you want by configuring:
- the route prefix (several routes are generated for each import process)
- the mapping (the required columns for your process)
- The process service (which must implement
Vinorcola\ImportBundle\Model\ImportConsumerInterface).
# config/packages/vinorcola_import.yaml vinorcola_import: temporaryDirectory: "%kernel.project_dir%/document-storage/tmp" imports: company_import: route_prefix: name: import.company. url: /company/import mapping: [ nationalIdentifier, companyName, address, city ] service: App\Model\CompanyImportHandler contact_import: route_prefix: name: import.contact. url: /contact/import mapping: [ firstName, lastName, emailAddress, phoneNumber ] service: App\Model\ContactImportHanlder
# config/routes/vinorcola_import.yaml import_routes: resource: '@VinorcolaImportBundle/Controller/' type: vinorcola_import
Then, the consume method of your process service will be called for line of data in the user's file, providing an array with the mapped columns and the line index:
public function consume(array $values, int $lineIndex): void;
For example, in the App\Model\CompanyImportHandler, the consume method will be called with a $values array containing the following keys:
nationalIdentifiercompanyNameaddresscity
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-06