4,000 emails/month for free | Mailtrap sends real emails now!

Take the Pain Out of Data Imports with Laravel Ingest

Last updated on by

Take the Pain Out of Data Imports with Laravel Ingest image

Laravel Ingest by Robin Kopp is a configuration-driven ETL (Extract, Transform, Load) package that replaces one-off import scripts with declarative importer classes. It handles files from a few hundred to tens of millions of rows by processing them through PHP Generators and Laravel Queues, keeping memory usage consistent regardless of file size.

Main Features

  • Declarative importer classes using a fluent IngestConfig builder
  • Automatic resolution of BelongsTo and BelongsToMany relationships
  • Duplicate handling strategies: SKIP, CREATE, UPDATE, and UPDATE_IF_NEWER
  • Dry-run mode to validate imports before writing to the database
  • Failed row tracking with downloadable CSV exports
  • Column aliasing to map varying header names to a single field
  • Dynamic model resolution based on row data
  • Import sources: file upload, filesystem disks (including S3), URL, FTP, and SFTP
  • Auto-generated Artisan commands and REST API endpoints per importer

Defining an Importer

After installing the package and running migrations, you create an importer class that implements IngestDefinition and returns an IngestConfig. By convention, these live in the App\Ingest namespace:

namespace App\Ingest;
 
use App\Models\Product;
use LaravelIngest\Contracts\IngestDefinition;
use LaravelIngest\DTOs\IngestConfig;
use LaravelIngest\Enums\DuplicateStrategy;
use LaravelIngest\Enums\SourceType;
 
class ProductImporter implements IngestDefinition
{
public function getConfig(): IngestConfig
{
return IngestConfig::for(Product::class)
->fromSource(SourceType::UPLOAD)
->keyedBy('sku')
->onDuplicate(DuplicateStrategy::UPDATE)
->map('Product Name', 'name')
->relate('Category', 'category', Category::class, 'slug')
->validate([
'sku' => 'required|string',
'Product Name' => 'required|string|min:3',
]);
}
}

Register the importer in your AppServiceProvider using the package's tag:

use LaravelIngest\IngestServiceProvider;
 
$this->app->tag([ProductImporter::class], IngestServiceProvider::INGEST_DEFINITION_TAG);

Running Imports

Once registered, the package exposes both an Artisan command and an HTTP endpoint for each importer.

Via CLI:

php artisan ingest:run product-importer --file=products.csv

Via API (multipart form upload):

POST /api/v1/ingest/upload/product-importer

For dry runs, append the --dry-run flag to the Artisan command to validate the file and surface any errors without touching the database.

Monitoring

The package includes several Artisan commands for checking on running or completed imports:

php artisan ingest:list # List registered importers
php artisan ingest:status {id} # Show progress and row statistics
php artisan ingest:cancel {id} # Stop an in-progress import
php artisan ingest:retry {id} # Reprocess only the failed rows

Equivalent REST endpoints are also available:

  • GET /api/v1/ingest — recent runs
  • GET /api/v1/ingest/{id} — status and statistics
  • GET /api/v1/ingest/{id}/errors/summary — aggregated error breakdown
  • GET /api/v1/ingest/{id}/failed-rows/download — CSV of rows that failed

Events

The package dispatches events throughout the import lifecycle — IngestRunStarted, ChunkProcessed, RowProcessed, IngestRunCompleted, and IngestRunFailed — which you can listen to for notifications or custom side effects.

You can find Laravel Ingest on GitHub and read the full documentation at the Laravel Ingest docs.

Yannick Lyn Fatt photo

Staff Writer at Laravel News and Full stack web developer.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Prism Workers AI — A Cloudflare Workers AI Provider for Prism PHP image

Prism Workers AI — A Cloudflare Workers AI Provider for Prism PHP

Read article
Take the Pain Out of Data Imports with Laravel Ingest image

Take the Pain Out of Data Imports with Laravel Ingest

Read article
Liminal: A Browser-Based IDE for Laravel Powered by WebAssembly image

Liminal: A Browser-Based IDE for Laravel Powered by WebAssembly

Read article
NativePHP v3.1: The Biggest Performance Leap Yet image

NativePHP v3.1: The Biggest Performance Leap Yet

Read article
Prompt Deck: Manage AI Prompts as Versioned Files in Laravel image

Prompt Deck: Manage AI Prompts as Versioned Files in Laravel

Read article
Laravel Prompts v0.3.15 Adds Streaming, Tasks, Autocomplete, and More image

Laravel Prompts v0.3.15 Adds Streaming, Tasks, Autocomplete, and More

Read article