PHPackages                             pvtl/csv-importer - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. pvtl/csv-importer

ActiveLibrary[Queues &amp; Workers](/categories/queues)

pvtl/csv-importer
=================

Background CSV import via Laravel queue jobs

1.1.5(1mo ago)053↓38.9%MITPHPPHP ^8.3CI passing

Since Apr 21Pushed 1mo agoCompare

[ Source](https://github.com/pvtl/csv-importer)[ Packagist](https://packagist.org/packages/pvtl/csv-importer)[ RSS](/packages/pvtl-csv-importer/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (8)Used By (0)

CSV Importer
============

[](#csv-importer)

A Laravel package for background CSV imports via Laravel queue jobs. Each row in the CSV is dispatched as an individual queued job, validated against your defined rules, and handed off to your own handler logic.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 12+
- A configured [queue driver](https://laravel.com/docs/queues#driver-prerequisites) (database, Redis, SQS, etc.)

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

[](#installation)

Then require the package:

```
composer require pvtl/csv-importer
```

Publish and run the migration to create the `failed_import_csv_rows` table:

```
php artisan pvtl-csv-importer:publish
php artisan migrate
```

Optionally publish an example service to use as a starting point:

```
php artisan pvtl-csv-importer:example
# Publishes to: app/Services/CSV/ExampleCsvImporterService.php
```

---

How It Works
------------

[](#how-it-works)

1. You extend `CsvImporterService` and define your columns, validation rules, and handler logic.
2. You instantiate your service class with a file stream resource. The import starts immediately.
3. One `CsvRowImportJob` is dispatched to the queue **per row**.
4. Each job calls `transformRow()` to normalise the raw row, then validates it against your `$columns` rules.
5. On success `handleRow()` is called; on failure `handleValidationError()` is called.
6. When the last row's job runs, `handleImportCompletion()` is called.

---

1. Creating an Importer Service
-------------------------------

[](#1-creating-an-importer-service)

Extend `CsvImporterService` and implement the two required abstract methods. Define your columns and their validation rules as a class property.

```
