Jump24 - Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

Iseed

orangehill/iseed image

Iseed stats

Downloads
5.1M
Stars
2,635
Open Issues
75
Forks
367

View on GitHub →

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

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
Acquaint Softtech logo

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
PhpStorm logo

PhpStorm

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

PhpStorm
Shift logo

Shift

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

Shift
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell