PHPackages                             riley19280/persistent-seeders - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. riley19280/persistent-seeders

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

riley19280/persistent-seeders
=============================

Persist data in a centralized and elegant way

v1.0.1(1y ago)08[4 PRs](https://github.com/Riley19280/persistent-seeders/pulls)MITPHPCI passing

Since May 29Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Riley19280/persistent-seeders)[ Packagist](https://packagist.org/packages/riley19280/persistent-seeders)[ RSS](/packages/riley19280-persistent-seeders/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (14)Versions (6)Used By (0)

 [![GitHub Workflow Status (master)](https://camo.githubusercontent.com/184ea939a2c2f9aed2fce75680b139ee7e62e82449df74d1d457965a5da8d582/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72696c657931393238302f70657273697374656e742d736565646572732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://github.com/riley19280/code-stencil/actions) [![Total Downloads](https://camo.githubusercontent.com/18e5329d0102ddfd92b2b94eb0cd945b1067c6668e19847158b9636f44ee7780/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696c657931393238302f70657273697374656e742d73656564657273)](https://packagist.org/packages/riley19280/persistent-seeders) [![Latest Version](https://camo.githubusercontent.com/0dbfce89231bf95c615c31fbacaa40953a03aa0122c203a3e4f2c97b92a4092c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696c657931393238302f70657273697374656e742d73656564657273)](https://packagist.org/packages/riley19280/persistent-seeders) [![License](https://camo.githubusercontent.com/72aff9613cbf423d74d74ffdb0595bfb32a9845e98163ed24b12c20f66dea416/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72696c657931393238302f70657273697374656e742d73656564657273)](https://packagist.org/packages/riley19280/persistent-seeders)

Persistent Seeders
==================

[](#persistent-seeders)

Persistent Seeders allow you to easily maintain your seeded data in a central location, and ensures that your data only gets inserted once.

A prime use case for this is for Roles. At the start of an application, you probably have a few roles that you want to support

```
class RoleSeeder extends PersistentSeeder {
    #[SeederId('6f7b4e00-97d9-4cb0-8a6b-c092e73755e3')]
    function initialRoles() {
        Role::create(['name' => 'Admin']);
        Role::create(['name' => 'User']);
    }
}
```

As development continues, you realize that you need more roles. The usual process for this would be to update your regular seeder, and also manually write a migration to insert the new role, and then run it in production. However, with Persistent Seeders this entire process can be automated. All you need to do is add a new function in the **same** file! It now looks like this:

```
class RoleSeeder extends PersistentSeeder {
    #[SeederId('6f7b4e00-97d9-4cb0-8a6b-c092e73755e3')]
    function initialRoles() {
        Role::create(['name' => 'Admin']);
        Role::create(['name' => 'User']);
    }

    #[SeederId('ef97efe9-40bd-4948-a1cd-feeb8fb1b27f')]
    function managerRole() {
        Role::create(['name' => 'Manager']);
    }
}
```

When the seeder runs again, only the new `Manager` role will be created. No messing with migrations, no searching for other roles that exist. Just a straightforward understanding of your applications' data.

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

[](#installation)

You can install the package via composer:

```
composer require riley19280/persistent-seeders
```

And then publish the migrations

```
php artisan vendor:publish --tag=persistent-seeder-migrations
```

Usage
-----

[](#usage)

Create a new database seeder and extend from `PersistentSeeders\PersistentSeeder`.

Then create your seed function, and add the `SeederId` attribute to the method. This attribute marks the method as a seeder, and relies on the uuid passed to it to prevent duplicate runs. If this id changes, the function will be run again.

```
php artisan make:seeder
```

```
class RoleSeeder extends PersistentSeeder {
    #[SeederId('6f7b4e00-97d9-4cb0-8a6b-c092e73755e3')]
    function initialRoles() {
        Role::create(['name' => 'Admin']);
    }
}
```

Extra Configuration
-------------------

[](#extra-configuration)

By default, the record of seed function run is stored in the `seeders` table. If you would like to change that location, you can publish the config file and change the `table_name` property.

```
php artisan vendor:publish --tag=persistent-seeder-config
```

```
return [
    'table_name' => 'my_custom_table_name',
];
```

Production Usage
----------------

[](#production-usage)

This package is perfectly suited for production usage, even though you may be hesitant to run "seeders" in production.

The most straightforward approach is to create a `ProductionSeeder` class as a regular seeder, and then run it as part of your deploy process.

```
class ProductionSeeder extends Seeder
{
    public function run(): void
    {
        // Each of these is a PersistentSeeder
        $this->call(TenantSeeder::class);
        $this->call(RoleSeeder::class);
        $this->call(UserSeeder::class);
    }
}
```

```
php artisan db:seed --class=ProductionSeeder --force
```

Alternatively, you can run each individually

```
php artisan db:seed --class=TenantSeeder --force
php artisan db:seed --class=RoleSeeder --force
php artisan db:seed --class=UserSeeder --force
```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance70

Regular maintenance activity

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

709d ago

### Community

Maintainers

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

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")[![Riley19280](https://avatars.githubusercontent.com/u/14127031?v=4)](https://github.com/Riley19280 "Riley19280 (3 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/riley19280-persistent-seeders/health.svg)

```
[![Health](https://phpackages.com/badges/riley19280-persistent-seeders/health.svg)](https://phpackages.com/packages/riley19280-persistent-seeders)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[illuminate/support

The Illuminate Support package.

583107.1M34.4k](/packages/illuminate-support)[illuminate/collections

The Illuminate Collections package.

27171.5M820](/packages/illuminate-collections)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M210](/packages/illuminate-pipeline)[illuminate/cookie

The Illuminate Cookie package.

224.3M120](/packages/illuminate-cookie)

PHPackages © 2026

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