PHPackages                             runasroot/module-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. runasroot/module-seeder

ActiveMagento2-module[Database &amp; ORM](/categories/database)

runasroot/module-seeder
=======================

Laravel-style database seeding for Magento 2

v1.4.0(3mo ago)361212MITPHPPHP ^8.1CI failing

Since Apr 18Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/run-as-root/magento-2-seeder)[ Packagist](https://packagist.org/packages/runasroot/module-seeder)[ RSS](/packages/runasroot-module-seeder/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (6)Dependencies (25)Versions (16)Used By (0)

Magento 2 Database Seeder
=========================

[](#magento-2-database-seeder)

[![CI](https://github.com/run-as-root/magento-2-seeder/actions/workflows/ci.yml/badge.svg)](https://github.com/run-as-root/magento-2-seeder/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Laravel-style database seeding for Magento 2 / Mage-OS. Define simple PHP / JSON / YAML files (or use the built-in Faker generators), run `bin/magento db:seed`, populate your dev environment with realistic products, categories, customers, orders, CMS content, reviews, cart rules, wishlists, and newsletter subscribers.

[![db:seed --generate=order:10 --fresh](docs/demo/seed-orders.gif)](docs/demo/seed-orders.gif)

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

[](#installation)

```
composer require runasroot/module-seeder --dev
bin/magento module:enable RunAsRoot_Seeder
bin/magento setup:upgrade
```

Quick Start
-----------

[](#quick-start)

1. Scaffold a seeder: `bin/magento db:seed:make`
2. Run `bin/magento db:seed`

Usage
-----

[](#usage)

```
# Run all seeders
bin/magento db:seed

# Run only specific types
bin/magento db:seed --only=customer,order

# Skip specific types
bin/magento db:seed --exclude=cms

# Wipe relevant data and re-seed
bin/magento db:seed --fresh

# Stop on first error
bin/magento db:seed --stop-on-error

# Combine flags
bin/magento db:seed --fresh --only=customer,product

# Show current DB counts of seeded entities
bin/magento db:seed:status
```

Scaffolding
-----------

[](#scaffolding)

`db:seed:make` creates one or more seeder files for you — no need to memorize the format.

```
# Interactive — multi-select entity types, per-type counts, one file per type.
# Labels show cascade hints, e.g. "order — cascades: customer, product, category".
bin/magento db:seed:make

# Flag-driven (CI / scripts) — single type per invocation.
bin/magento db:seed:make --type=order --count=100 --format=php

# Overwrite an existing file
bin/magento db:seed:make --type=order --count=100 --force
```

Interactive mode pairs a multi-select (use space to toggle, enter to confirm) with a per-type count prompt — picking `order`, `customer` writes both `OrderSeeder.`and `CustomerSeeder.`. Shared prompts (locale, seed, format) apply to every file written in the same run. If any target already exists you'll get a per-file overwrite confirm; declined files are skipped and the rest continue.

Flag-driven mode stays single-type (`--type=X --count=N`); multi-type via flags is not supported yet.

Available flags:

FlagDefaultNotes`--type`—required non-interactive`--count`—required non-interactive`--format``php``php` / `json` / `yaml``--name``{Type}Seeder`file name without extension`--locale``en_US`Faker locale`--seed`randomFaker seed for deterministic output`--force``false`overwrite existing fileSeeder Formats
--------------

[](#seeder-formats)

Seeder files live in `dev/seeders/` and must end in `Seeder.`. Three formats are supported:

FormatExtensionUse whenPHP`.php`Array or class with loops / Faker / conditionalsJSON`.json`Machine-generated fixtures or cross-language toolsYAML`.yaml` / `.yml`Human-readable fixturesAll three share the same payload shape: `type`, `data` (or `count`), and optional `order`/`locale`/`seed`.

### Array-Based (PHP)

[](#array-based-php)

Create a PHP file ending in `Seeder.php` that returns an array with `type` and `data`:

```
