承接 dmt-software/laravel-import-reader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dmt-software/laravel-import-reader

最新稳定版本:v0.2.1

Composer 安装命令:

composer require dmt-software/laravel-import-reader

包简介

import reader that can handles huge imports

README 文档

README

Laravel bridge for dmt-software/import-reader to iterate over the contents of (huge) imports.

Support

This package is tested on and requires laravel >= 8.0.

Installation

composer require dmt-software/laravel-import-reader

The service provider can be automatically registered by auto-discovery. Otherwise, register it manually add it to config/app.php:

'providers' => [
    // ...
    DMT\Laravel\Import\Reader\Providers\ImportReaderServiceProvider::class,
];

To publish the configuration file:

php artisan vendor:publish --provider="DMT\Laravel\Import\Reader\Providers\ImportReaderServiceProvider"

Configuration

The configuration has entries for custom sanitizers, handlers and a custom error handler. See the config/reader.php file for their usage or the dmt-software/import-reader documentation.

Usage

A file called items.json contains the following data:

[
  { 
    "id": 1,
    "name": "item-name",
    // ...
  },
  {
    "id": 2,
    "name": "item2-name",
    // ...
  },
  // ...
]

That can be read into chunks that can be imported into a database:

use DMT\Laravel\Import\Reader\Facades\ImportReader;

/** @var iterable<int, array> $items */
$items = ImportReader::buildToArrayReader(
    'directory-to/items.json', [
        'path' => '.'
    ])->read();

foreach ($items as $row => $item) {
    // process the items 
    if (!empty($item['name'])) {
        Item::updateOrCreate($item);
    }
}

Or the reader builder can be injected into your classes or methods.

use DMT\Import\Reader\ReaderBuilder;
use Illuminate\Console\Command;

class MyImportCommand extends Command
{
    protected $signature = 'import:items {file}';
    
    public function handle(ReaderBuilder $builder)
    {
        $reader = $builder->build($this->argument('file'), []);
        
        foreach ($reader->read($this->argument('skip')) as $item) {
            // process item
        }
    }
}

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固