PHPackages                             falkan3/csv-seeder - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. falkan3/csv-seeder

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

falkan3/csv-seeder
==================

Allows seeding of the database with CSV files

v2.0.3(5y ago)063MITPHPPHP &gt;=7.4

Since Feb 13Pushed 3y agoCompare

[ Source](https://github.com/Falkan3/laravel-csv-seeder)[ Packagist](https://packagist.org/packages/falkan3/csv-seeder)[ RSS](/packages/falkan3-csv-seeder/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (3)Versions (14)Used By (0)

CSV Seeder
----------

[](#csv-seeder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8e82384364566bdd24814b8f047877ce464192720e3741585fef6322712d6511/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c796e7361726d792f6373762d7365656465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/flynsarmy/csv-seeder)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://github.com/Flynsarmy/laravel-csv-seeder/workflows/CI/badge.svg)](https://github.com/Flynsarmy/laravel-csv-seeder/workflows/CI/badge.svg)[![Quality Score](https://camo.githubusercontent.com/341487d2ce453dc982d7767722544d824bf13b20d7130df47188066b4345f9e0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f466c796e7361726d792f6c61726176656c2d6373762d7365656465722f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/flynsarmy/laravel-csv-seeder)[![Total Downloads](https://camo.githubusercontent.com/8155b7d570bf3dab7d03d2ce8ffd5fa90f8f444e95ff4028e2b95624e3f4167d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c796e7361726d792f6373762d7365656465723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/flynsarmy/csv-seeder)

### Seed your database with CSV files

[](#seed-your-database-with-csv-files)

This package allows CSV based seeds.

### Installation

[](#installation)

Require this package in your composer.json and run composer update (or run `composer require flynsarmy/csv-seeder:2.*` directly):

**For PHP 7.4+**

```
"flynsarmy/csv-seeder": "2.0.*"

```

**For older PHP versions**

```
"flynsarmy/csv-seeder": "1.*"

```

### Usage

[](#usage)

Your CSV's header row should match the DB columns you wish to import. IE to import *id* and *name* columns, your CSV should look like:

```
id,name
1,Foo
2,Bar

```

Seed classes must extend `Falkan3\CsvSeeder\CsvSeeder`, they must define the destination database table and CSV file path, and finally they must call `parent::run()` like so:

```
use Falkan3\CsvSeeder\CsvSeeder;

class StopsTableSeeder extends CsvSeeder {

	public function __construct()
	{
		$this->table = 'your_table';
		$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
	}

	public function run()
	{
		// Recommended when importing larger CSVs
		DB::disableQueryLog();

		// Uncomment the below to wipe the table clean before populating
		DB::table($this->table)->truncate();

		parent::run();
	}
}

```

Drop your CSV into */database/seeds/csvs/your\_csv.csv* or whatever path you specify in your constructor above.

### Configuration

[](#configuration)

In addition to setting the database table and CSV filename, the following configuration options are available. They can be set in your class constructor:

- `connection` (string '') Connection to use for inserts. Leave empty for default connection.
- `insert_chunk_size` (int 500) An SQL insert statement will trigger every `insert_chunk_size` number of rows while reading the CSV
- `csv_delimiter` (string ,) The CSV field delimiter.
- `hashable` (array \[password\]) List of fields to be hashed before import, useful if you are importing users and need their passwords hashed. Uses `Hash::make()`. Note: This is EXTREMELY SLOW. If you have a lot of rows in your CSV your import will take quite a long time.
- `offset_rows` (int 0) How many rows at the start of the CSV to ignore. Warning: If used, you probably want to set a mapping as your header row in the CSV will be skipped.
- `mapping` (array \[\]) Associative array of csvCol =&gt; dbCol. See examples section for details. If not specified, the first row (after offset) of the CSV will be used as the mapping.
- `should_trim` (bool false) Whether to trim the data in each cell of the CSV during import.
- `timestamps` (bool false) Whether or not to add *created\_at* and *updated\_at* columns on import.
    - `created_at` (string current time in ISO 8601 format) Only used if `timestamps` is `true`
    - `updated_at` (string current time in ISO 8601 format) Only used if `timestamps` is `true`

### Examples

[](#examples)

CSV with pipe delimited values:

```
public function __construct()
{
	$this->table = 'users';
	$this->csv_delimiter = '|';
	$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
}

```

Specifying which CSV columns to import:

```
public function __construct()
{
	$this->table = 'users';
	$this->csv_delimiter = '|';
	$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
	$this->mapping = [
	    0 => 'first_name',
	    1 => 'last_name',
	    5 => 'age',
	];
}

```

Trimming the whitespace from the imported data:

```
public function __construct()
{
	$this->table = 'users';
	$this->csv_delimiter = '|';
	$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
	$this->mapping = [
	    0 => 'first_name',
	    1 => 'last_name',
	    5 => 'age',
	];
	$this->should_trim = true;
}

```

Skipping the CSV header row (Note: A mapping is required if this is done):

```
public function __construct()
{
	$this->table = 'users';
	$this->csv_delimiter = '|';
	$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
	$this->offset_rows = 1;
	$this->mapping = [
	    0 => 'first_name',
	    1 => 'last_name',
	    2 => 'password',
	];
	$this->should_trim = true;
}

```

Specifying the DB connection to use:

```
public function __construct()
{
	$this->table = 'users';
	$this->connection = 'my_connection';
	$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
}

```

### Migration Guide

[](#migration-guide)

#### 2.0

[](#20)

- `$seeder->hashable` is now an `array` of columns rather than a single column name. Wrap your old string value in `[]`.

### License

[](#license)

CsvSeeder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 72.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~208 days

Recently: every ~13 days

Total

12

Last Release

2188d ago

Major Versions

v1.0.7 → v2.0.02020-03-27

PHP version history (3 changes)v1.0PHP &gt;=5.3.0

v2.0.0PHP &gt;=7

v2.0.2PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ca0a8a308391ec21dd333304bc4a4a6a3ea00dd3cd56f3b5c5aa2b2ba51a1dc?d=identicon)[falkan3](/maintainers/falkan3)

---

Top Contributors

[![Flynsarmy](https://avatars.githubusercontent.com/u/334808?v=4)](https://github.com/Flynsarmy "Flynsarmy (42 commits)")[![Falkan3](https://avatars.githubusercontent.com/u/15730072?v=4)](https://github.com/Falkan3 "Falkan3 (11 commits)")[![teodortalov](https://avatars.githubusercontent.com/u/2781820?v=4)](https://github.com/teodortalov "teodortalov (2 commits)")[![fabiosato](https://avatars.githubusercontent.com/u/607586?v=4)](https://github.com/fabiosato "fabiosato (1 commits)")[![jackfruh](https://avatars.githubusercontent.com/u/334880?v=4)](https://github.com/jackfruh "jackfruh (1 commits)")[![slakbal](https://avatars.githubusercontent.com/u/4387265?v=4)](https://github.com/slakbal "slakbal (1 commits)")

---

Tags

laravelcsvseedingseedseeds

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/falkan3-csv-seeder/health.svg)

```
[![Health](https://phpackages.com/badges/falkan3-csv-seeder/health.svg)](https://phpackages.com/packages/falkan3-csv-seeder)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[flynsarmy/csv-seeder

Allows seeding of the database with CSV files

2561.6M1](/packages/flynsarmy-csv-seeder)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k24.9M47](/packages/rap2hpoutre-fast-excel)[jeroenzwart/laravel-csv-seeder

Seed the database with Laravel using CSV files

97395.6k2](/packages/jeroenzwart-laravel-csv-seeder)[crockett/csv-seeder

Database seeding using CSV files

23173.5k](/packages/crockett-csv-seeder)[bfinlay/laravel-excel-seeder

Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files

3944.4k](/packages/bfinlay-laravel-excel-seeder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
