Package

Orangehill Iseed

Generate a new Laravel database seed file based on data from the existing database table.

Package

orangehill/iseed

View on GitHub →

Inverse Seed Generator (iSeed)

The Inverse Seed Generator (iSeed) is a Laravel package designed to efficiently generate seed files from existing database tables. This tool is ideal for developers who need to replicate database contents in a structured and reusable way, particularly useful in testing and staging environments.

Key Features

  • Generate Seed Files: Automatically creates seed files based on existing database tables.
  • Custom Class Names: Supports prefixes and suffixes for Seeder class names to avoid overwriting existing seeds.
  • Flexible Usage: Allows specification of multiple tables, custom DB connections, chunk sizes, max rows, and more.
  • Artisan Support: Fully integrated with Laravel's Artisan command-line tool, enhancing its functionality.
  • Event Hooks: Provides options to execute Laravel events before and after seed generation.

Installation and Setup

  1. Install via Composer:

    composer require orangehill/iseed

    For Laravel 5.3.7 and below or Laravel 4, specify the version:

    composer require orangehill/iseed:2.2 # For Laravel 5.3.7 and below
    composer require orangehill/iseed:1.1 # For Laravel 4
  2. Register Service Provider (For Laravel 5.4 and below as newer versions support auto-discovery):

    Orangehill\Iseed\IseedServiceProvider::class,

Usage

To generate a seed file for a database table:

php artisan iseed my_table

This command will create a new seed file in the /database/seeds directory with the SQL data from my_table.

Advanced Options

  • Multiple Tables: php artisan iseed table1,table2
  • Overwrite Existing Seeds: --force
  • Limit Rows: --max=10
  • Custom DB Connection: --database=custom_connection
  • Exclude Columns: --exclude=id,created_at

Practical Examples

Generate seeds with custom class names:

php artisan iseed users --classnameprefix=Custom

Exclude specific columns and limit the number of rows:

php artisan iseed users --exclude=email,created_at --max=50

Conclusion

iSeed is a powerful tool for Laravel developers, simplifying the process of generating seed files from existing databases, making it easier to manage and replicate database states across different environments. Whether you're working on a small project or a large enterprise application, iSeed offers the flexibility and efficiency needed for effective database management and testing.

Orangehill Iseed Related Articles

iSeed – Laravel Inverse Seed Generator image

iSeed – Laravel Inverse Seed Generator

Read article

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing