PHPackages                             timokoerber/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. timokoerber/laravel-json-seeder

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

timokoerber/laravel-json-seeder
===============================

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

1.0.1(5y ago)4835.8k↓33.9%3[1 issues](https://github.com/TimoKoerber/laravel-json-seeder/issues)MITPHP

Since Jul 7Pushed 5y ago3 watchersCompare

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

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

[![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="TimoKoerber\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' => [
    ...

    TimoKoerber\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(TimoKoerber\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

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~108 days

Total

2

Last Release

2033d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aa70b5e33cf514aec8161e102a5ebace2ce3441542d3eb1d34fc9c290667404d?d=identicon)[TimoKoerber](/maintainers/TimoKoerber)

---

Top Contributors

[![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

datadatabasejsonlaravelseedseederseeder-tableseederslaraveldatabaseseederseeds

### Embed Badge

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

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

PHPackages © 2026

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