PHPackages                             lucaciotti/laravel-json-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. [Database &amp; ORM](/categories/database)
4. /
5. lucaciotti/laravel-json-seeder

ActiveProject[Database &amp; ORM](/categories/database)

lucaciotti/laravel-json-seeder
==============================

Create and use JSON files to seed your database in your Laravel applications

1.1.7(4y ago)1269MITPHP

Since Jul 7Pushed 4y agoCompare

[ Source](https://github.com/lucaciotti/laravel-json-seeder)[ Packagist](https://packagist.org/packages/lucaciotti/laravel-json-seeder)[ RSS](/packages/lucaciotti-laravel-json-seeder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (0)

INTRO
-----

[](#intro)

This is a modified version of the brilliant package created by [TimoKoerber](https://github.com/TimoKoerber/laravel-json-seeder).

In this version I changed the call to "json\_decode" in the Seeder side with the package created by [Halaxa](https://github.com/halaxa/json-machine) "json-machine".

- "json\_decode" often causes Allowed Memory Size Exhausted, when it has to process large files (which can often happen in database seeding).
- the "halaxa / json-machine" offers a very easy to use and memory efficient drop-in replacement for inefficient iteration of big JSON files

In addition, I added a few more configurations for the seeding procedure.

myChangelog
===========

[](#mychangelog)

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

\[1.1.1\] - 2021-04-16
----------------------

[](#111---2021-04-16)

### Fixed

[](#fixed)

- Improved "Exception -&gt; File Empty" Read content to each file kept causing "Allowed Memory Size Exhausted"
- Inserted timer calculation for each seeding file

\[1.1\] - 2021-04-16
--------------------

[](#11---2021-04-16)

### First Release

[](#first-release)

---

[![Laravel JSON Seeder](https://user-images.githubusercontent.com/65356688/86782944-fe5aa180-c05f-11ea-9267-1581c7f991e1.jpg)](https://user-images.githubusercontent.com/65356688/86782944-fe5aa180-c05f-11ea-9267-1581c7f991e1.jpg)

Laravel JSON Seeder
-------------------

[](#laravel-json-seeder)

Create and use JSON files to seed your database in your Laravel applications.

This package works both ways!

- Export your database into JSON files
- Use JSON files to seed your database

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

[](#installation)

**Require this package** with composer. It is recommended to only require the package for development.

```
composer require timokoerber/laravel-json-seeder --dev
```

Next you need to **publish** the config file and register the required commands with ...

```
php artisan vendor:publish --provider="LucaCiotti\LaravelJsonSeeder\JsonSeederServiceProvider"
```

This will create the file `config/jsonseeder.php` where you can find the configurations.

Next add the JsonSeederServiceProvider to the `providers` array in `config/app.php` ...

```
// config/app.php

'providers' => [
    ...

    LucaCiotti\LaravelJsonSeeder\JsonSeederServiceProvider::class,

    ...
]
```

Creating JSON seeds from database
---------------------------------

[](#creating-json-seeds-from-database)

[![Laravel JSON Seeder - Creating JSON seeds from database](https://user-images.githubusercontent.com/65356688/86143845-3ceadc00-baf5-11ea-956f-d707b88d148c.gif)](https://user-images.githubusercontent.com/65356688/86143845-3ceadc00-baf5-11ea-956f-d707b88d148c.gif)

Of course you can create the JSON files manually. But if you already have a good development database, you can easily export it into JSON seeds.

You can create seeds for **every table in your database** by calling ...

```
php artisan jsonseeds:create
```

This will create one JSON file for watch table in your database (i.e. table *users* -&gt; *users.json*, table *posts* -&gt; *posts.json*, etc.).

If you only want to create a seed of **one specific table** (i.e. `users`), call ...

```
php artisan jsonseeds:create users
```

Existing files **won't be overwritten** by default. If you call the command again, a **sub-directory will be created** and the JSON seeds will be stored there. If you want to **overwrite the existing seeds**, use the `overwrite` option like ...

```
php artisan jsonseeds:create users -o|--overwrite
```

or just **use the command** ...

```
php artisan jsonseeds:overwrite users
```

Seeding
-------

[](#seeding)

[![Laravel JSON Seeder - Seeding](https://user-images.githubusercontent.com/65356688/86143769-23e22b00-baf5-11ea-90e6-0631a41d81c4.gif)](https://user-images.githubusercontent.com/65356688/86143769-23e22b00-baf5-11ea-90e6-0631a41d81c4.gif)

Go to your `databas/seeds/DatabaseSeeder.php` and add the JsonSeeder inside the `run()` method like this ...

```
// database/seeds/DatabaseSeeder.php

class DatabaseSeeder extends Seeder
{
    public function run()
    {
        $this->call(LucaCiotti\LaravelJsonSeeder\JsonDatabaseSeeder::class);
    }
}
```

You can now call the JSON Seeder with the **usual Artisan command** ...

```
php artisan db:seed
```

Settings &amp; Configurations
-----------------------------

[](#settings--configurations)

### Directory

[](#directory)

By default your seeds will be written into or read from the directory `/database/json`. If you want a different directory, you can add the environment variable `JSON_SEEDS_DIRECTORY` in your `.env` file ...

```
# .env

JSON_SEEDS_DIRECTORY=database/json

```

### Ignoring tables

[](#ignoring-tables)

Some tables in your database might not require any seeds. If you want to ignore these tables, you can put them into the setting `ignore-tables` in the `/config.jsonseeder.php`

```
// config/jsonseeder.php

'ignore-tables' => [
    'migrations',
    'failed_jobs',
    'password_resets',
]
```

If a table in your database is empty, the LaravelJsonSeeder will create a JSON file with an empty array by default. This might be useful if you want your seeds to truncate this table. If you don't want this, you can change the setting `ignore-empty-tables` in `config/jsonseeder.php`, so no JSON seed will be created.

```
// config/jsonseeder.php

'ignore-empty-tables' => true
```

> **Important!!!** Do not forget to clear the cache after editing the config file: `php artisan cache:clear`

### Environments

[](#environments)

The environment variable `JSON_SEEDS_DIRECTORY` might be useful if you are using seeds in Unit Tests and want to use different seeds for this.

```
- database
  - json
      - development
        - comapanies.json
        - users.json
        - posts.json
      - testing
        - users.json
        - posts.json

```

#### Development

[](#development)

```
# .env

JSON_SEEDS_DIRECTORY=database/json/development

```

#### Testing

[](#testing)

```
// phpunit.xml

```

Errors &amp; Warnings
---------------------

[](#errors--warnings)

[![jsonseeder-errors](https://user-images.githubusercontent.com/65356688/86142165-2e9bc080-baf3-11ea-99b8-9bef46cd61f2.gif)](https://user-images.githubusercontent.com/65356688/86142165-2e9bc080-baf3-11ea-99b8-9bef46cd61f2.gif)

ErrorTypeSolutionTable does not exist!ErrorThe name of the JSON file does not match any table. Check the filename or create the table.JSON syntax is invalid!ErrorThe JSON text inside the file seems to be invalid. Check if the JSON format is correct.Exception occured! Check logfile!ErrorThere seems to be a problem with the Database. Check your system and your default logfile.JSON file is empty!ErrorThe JSON file is completely empty, which makes it useless. If it should truncate the table, provide an empty array `[]`. Otherwise delelte it.JSON file has no rows!WarningThe JSON file contains only an empty array `[]`. This results in a truncated table and might not be intended.Missing fields!WarningAt least one row in the JSON file is missing a field, that is present in the database table. Check for typos or provide it in the JSON file.Unknown fields!WarningAt least one row in the JSON file has a field that does not exist in the database. Check for typos or make sure to add it to the database table.License
-------

[](#license)

Copyright © Timo Körber

Laravel JSON Seeder is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 68.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 ~40 days

Total

14

Last Release

1613d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86ca85af247e55ef198de57ace124a037c0701a0a1cfa45bfac1009b102a547c?d=identicon)[Luca Ciotti](/maintainers/Luca%20Ciotti)

---

Top Contributors

[![lucaciotti](https://avatars.githubusercontent.com/u/5623252?v=4)](https://github.com/lucaciotti "lucaciotti (13 commits)")[![TimoKoerber](https://avatars.githubusercontent.com/u/65356688?v=4)](https://github.com/TimoKoerber "TimoKoerber (5 commits)")[![mintbridge](https://avatars.githubusercontent.com/u/32777?v=4)](https://github.com/mintbridge "mintbridge (1 commits)")

---

Tags

laraveldatabaseseederseeds

### Embed Badge

![Health badge](/badges/lucaciotti-laravel-json-seeder/health.svg)

```
[![Health](https://phpackages.com/badges/lucaciotti-laravel-json-seeder/health.svg)](https://phpackages.com/packages/lucaciotti-laravel-json-seeder)
```

###  Alternatives

[timokoerber/laravel-json-seeder

Create and use JSON files to seed your database in your Laravel applications

4835.8k](/packages/timokoerber-laravel-json-seeder)

PHPackages © 2026

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