PHPackages                             makeabledk/laravel-production-seeding - 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. makeabledk/laravel-production-seeding

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

makeabledk/laravel-production-seeding
=====================================

v3.2.0(2w ago)72.7k2CC-BY-SA-4.0PHPPHP ^8.1CI passing

Since Jun 27Pushed 2w ago1 watchersCompare

[ Source](https://github.com/makeabledk/laravel-production-seeding)[ Packagist](https://packagist.org/packages/makeabledk/laravel-production-seeding)[ RSS](/packages/makeabledk-laravel-production-seeding/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (12)Versions (21)Used By (0)

Laravel Production Seeding
==========================

[](#laravel-production-seeding)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1bca7d4fa4ecc8890214b2255ebc5a7db909bb40416e9e4abf9bacb524fc81d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616b6561626c65646b2f6c61726176656c2d70726f64756374696f6e2d73656564696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/makeabledk/laravel-production-seeding)[![Build Status](https://camo.githubusercontent.com/36675b6628180ade1ee776b8514c0464c54515be2ad5e5a210df74261d109c8c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616b6561626c65646b2f6c61726176656c2d70726f64756374696f6e2d73656564696e672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/makeabledk/laravel-production-seeding)[![StyleCI](https://camo.githubusercontent.com/a85e326ce33b03fa5d7ee41311a8f9e1fff6602ad757858decd214532aa02f2d/68747470733a2f2f7374796c6563692e696f2f7265706f732f39353535323838352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/95552885)

This package provides a handy way to work with production seeding in Laravel.

Consider you have database tables you want to keep in-sync across environments. For instance some configuration table where you need to ensure a fixed number of rows, but not necessarily overwrite the values.

Laravel Production Seeding helps you achieve this in a styleful manner!

Inspired by Edward Coleridge Smith's Laracon talk on the subject: [How to avoid database migration hell (YouTube)](https://www.youtube.com/watch?v=lH-FLJ363-Q)

\--

Makeable is web- and mobile app agency located in Aarhus, Denmark.

Install
-------

[](#install)

You can install this package via composer:

```
composer require makeabledk/laravel-production-seeding
```

Usage
-----

[](#usage)

Create a Laravel seeder as you normally would. Next implement the SyncStrategy, and apply the fixed rows onto your model from the run method.

Finally you can run the seeder as part of your deployment process to ensure all environments implements the same basic blueprint.

Examples
--------

[](#examples)

### Syncing a configuration table

[](#syncing-a-configuration-table)

Sync a database configuration table with an array-blueprint. Note how we hardcode the service-id, but allow for separate keys.

```
class ConfigSeeder extends Seeder
{
    use \Makeable\ProductionSeeding\SyncStrategy;

    public $rows = [
        [
            'key' => 'some_service_id',
            'value' => '123456'
        ],
        [
            'key' => 'some_service_public_key',
        ],
        [
            'key' => 'some_service_private_key',
        ],
    ];

    public function run()
    {
        $this->apply($this->rows, Config::class, 'key');
    }
}
```

Results in

```
| id | key                      | value  |
|----|--------------------------|--------|
| 1  | some_service_id          | 123456 |
| 2  | some_service_public_key  | NULL   |
| 3  | some_service_private_key | NULL   |

```

### Syncing rows with an order

[](#syncing-rows-with-an-order)

Sometimes you may want to have a fixed list of items and then apply a certain order in the database.

This can easily be achieved with a `AppendsSortOrder` trait. Re-arranging the array items will change the order value in the database, but leave the id's intact.

```
class LanguageSeeder extends Seeder
{
    use \Makeable\ProductionSeeding\SyncStrategy,
        \Makeable\ProductionSeeding\AppendsSortOrder;

    protected $sortKey = 'order'; // default if omitted

    public $rows = [
        [
            'code' => 'en_GB',
            'name' => 'English (GB)',
        ],
        [
            'code' => 'en_US',
            'name' => 'English (US)',
        ],
        [
            'code' => 'da_DK',
            'name' => 'Danish',
        ],
    ];

    public function run()
    {
        $this->apply($this->rows, LanguagesModel::class, 'code');
    }
}
```

Results in...

```
| id | code  | name         | order |
|----|-------|--------------|-------|
| 1  | en_GB | English (GB) | 1     |
| 2  | en_US | English (US) | 2     |
| 3  | da_DK | Danish       | 3     |

```

You could then re-arrange the array and run the seeder again. Then you could have...

```
| id | code  | name         | order |
|----|-------|--------------|-------|
| 1  | en_GB | English (GB) | 2     |
| 2  | en_US | English (US) | 1     |
| 3  | da_DK | Danish       | 3     |

```

Pretty cool, right?

### Appending a configuration table

[](#appending-a-configuration-table)

Using previous sync-strategy, any rows manually added to the database table would be deleted on seeding.

If this is not the behaviour you wish for, you may instead use `AppendStrategy` which would only append the new rows.

Let's assume our previous `config` table has an existing row:

```
| id | key                      | value      |
|----|--------------------------|------------|
| 1  | github_username          | makeabledk |

```

Next we setup our `ConfigSeeder` with an `AppendStrategy`:

```
class ConfigSeeder extends Seeder
{
    use \Makeable\ProductionSeeding\AppendStrategy;

    public $rows = [
        [
            'key' => 'some_service_id',
            'value' => '123456'
        ],
        [
            'key' => 'some_service_public_key',
        ],
        [
            'key' => 'some_service_private_key',
        ],
    ];

    public function run()
    {
        $this->apply($this->rows, Config::class, 'key');
    }
}
```

Now our table would have the existing row plus the 3 new ones:

```
| id | key                      | value      |
|----|--------------------------|------------|
| 1  | github_username          | makeabledk |
| 2  | some_service_id          | 123456     |
| 3  | some_service_public_key  | NULL       |
| 4  | some_service_private_key | NULL       |

```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Contributing
------------

[](#contributing)

We are happy to receive pull requests for additional functionality. Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Rasmus Christoffer Nielsen](https://github.com/rasmuscnielsen)
- [Edward Coleridge Smith: How to avoid database migration hell (YouTube)](https://www.youtube.com/watch?v=lH-FLJ363-Q)
- [All Contributors](../../contributors)

License
-------

[](#license)

Attribution-ShareAlike 4.0 International. Please see [License File](LICENSE.md) for more information.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 96% 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 ~293 days

Recently: every ~244 days

Total

12

Last Release

17d ago

Major Versions

v0.9.0 → v1.0.02019-01-23

v1.3.0 → v2.0.02022-01-26

v2.0.0 → v3.0.02023-08-23

v0.3.1 → v3.0.12023-08-23

PHP version history (4 changes)v0.9.0PHP &gt;=7.0.0

v1.1.0PHP &gt;=7.2.0

v2.0.0PHP ^8.0

v3.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22741894?v=4)[Makeable ApS](/maintainers/makeabledk)[@makeabledk](https://github.com/makeabledk)

---

Top Contributors

[![rasmuscnielsen](https://avatars.githubusercontent.com/u/8465957?v=4)](https://github.com/rasmuscnielsen "rasmuscnielsen (24 commits)")[![ottothebot](https://avatars.githubusercontent.com/u/261808813?v=4)](https://github.com/ottothebot "ottothebot (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/makeabledk-laravel-production-seeding/health.svg)

```
[![Health](https://phpackages.com/badges/makeabledk-laravel-production-seeding/health.svg)](https://phpackages.com/packages/makeabledk-laravel-production-seeding)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

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