rashiqulrony/laravel-csv-import
Composer 安装命令:
composer require rashiqulrony/laravel-csv-import
包简介
Import Very Large CSV Without File Store and Chunk Upload system Laravel package to export and import CSV files in a memory-optimized way
关键字:
README 文档
README
A Laravel package to import large CSV files efficiently using chunked memory processing, on-the-fly UTF-8 conversion, and no temporary storage overhead.
📦 Installation
Install via Composer:
composer require rashiqulrony/laravel-csv-import
If you're using Laravel <5.5 or your Laravel version doesn't support package auto-discovery, add the service provider manually:
// config/app.php 'providers' => [ Rashiqulrony\CSVImport\Providers\AppServiceProvider::class, ];
⚙️ Configuration
Publish the config file (optional):
php artisan vendor:publish --provider="Rashiqulrony\CSVImport\Providers\AppServiceProvider" --tag=config
This creates a file: config/csvimport.php
return [ 'chunk_size' => 200, // Number of rows to return per batch ];
🚀 Usage
✅ Basic Example
use Rashiqulrony\CSVImport; public function upload(Request $request) { $request->validate([ 'file' => 'required|file|mimes:csv', ]); $result = CSVImport::upload($request->file('file')); if (!empty($result) && is_array($result)) { foreach ($result as $key => $value) { foreach ($result[$key] as $data) { // Process or save the row (e.g. DB::table(...)->insert($row)) } } } else { return back()->with('error', 'Data not found or invalid file.'); } return back()->with('success', 'CSV imported successfully!'); }
📥 Method: CSVImport::upload($file)
| Returns | Description |
|---|---|
array |
On success: returns a chunk of rows (associative arrays). |
['status' => false, 'message' => '...'] |
On failure. |
✅ Features
- Detects and converts multiple encodings to UTF-8
- Skips invalid rows (missing fields, malformed headers)
- Efficient memory usage with chunking
- No need to manually store or manage temp files
🧪 Supported Encodings
- UTF-8
- UTF-16LE / UTF-16BE
- Windows-1252
- ISO-8859-1
📂 Directory Structure
laravel-csv-import/
├── src/
│ ├── CSVImport.php
│ └── Providers/
│ └── AppServiceProvider.php
├── config/
│ └── csvimport.php
├── composer.json
└── README.md
📝 License
This package is open-sourced software licensed under the MIT license.
👤 Author
Rashiqul Rony
📧 rashiqulrony@gmail.com
🔗 github.com/rashiqulrony
rashiqulrony/laravel-csv-import 适用场景与选型建议
rashiqulrony/laravel-csv-import 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「csv to array」 「csv import」 「RashiqulRony」 「laravel csv」 「csv package」 「laravel csv import」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rashiqulrony/laravel-csv-import 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rashiqulrony/laravel-csv-import 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rashiqulrony/laravel-csv-import 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A set of useful PHP classes.
Parse use statements for a reflection object
Tool for copying data from a production database to a dev database. Also useful for making backups of production databases.
Trait providing methods to set class properties with an array.
A fork of konnco/filament-import with support of Laravel 11 since the default importer of Filament 3 is nonsense for basic use case.
Traits to build collections of specific objects
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-01