orangehill/iseed
Generate Laravel database seeders from existing table data. iSeed adds an artisan command to export one or many tables (or all tables) into seeder classes, with optional class name prefix/suffix to avoid overwriting. Supports Laravel 8–13 (PHP 8+).
?Filesystem, ?Composer) in Iseed constructor to resolve PHP 8.4 deprecation warning (#231)Thanks to @dragonfly4 for reporting!
.svg format for live updatesnamespace Database\Seedersuse Illuminate\Database\Seedertruncate() to delete() to match actual codedatabase/seeds to database/seeders (Laravel 8+)--reset-sequences option for PostgreSQL (#160): Resets PostgreSQL sequences after seeding to prevent "duplicate key value violates unique constraint" errors when inserting new records.php artisan iseed users --reset-sequences
prettifyArray() function now preserves whitespace inside multiline string values, fixing issues with YAML, JSON, or other data where indentation is significant.Thanks to @Magentron for reporting the whitespace issue and @cjlaborde for reporting the PostgreSQL sequence issue.
--skip option: Skip a specified number of rows before exporting. Useful for paginating through large datasets.# Export first 1000 rows
php artisan iseed users --max=1000 --orderby=id
# Export next 1000 rows (skip first 1000)
php artisan iseed users --max=1000 --skip=1000 --orderby=id
# Export rows 2001-3000
php artisan iseed users --max=1000 --skip=2000 --orderby=id
ASC when using --orderby without explicit --directionThanks to @whoisryosuke for PR #143.
--skip-fk-checks option: Disable foreign key checks during seeding. Useful for tables with FK constraints that would fail on delete/insert operations.php artisan iseed users --skip-fk-checks
This generates:
\DB::statement('SET FOREIGN_KEY_CHECKS=0;');
\DB::table('users')->delete();
\DB::table('users')->insert(...);
\DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Note: This generates MySQL-specific statements.
Thanks to @aomini for PR #157.
--database with a non-default connection, the generated seeder now properly uses DB::connection('name')->table() instead of just DB::table(). This prevents accidental data operations on the wrong database.# Default database - generates: \DB::table('users')
php artisan iseed users
# Non-default database - generates: \DB::connection('mysql2')->table('users')
php artisan iseed users --database=mysql2
Thanks to @Endy-c for PR #212.
config/iseed.php to customize the generated seed file format.Create config/iseed.php in your Laravel application:
<?php
return [
'stub_path' => resource_path('stubs'),
];
Then create your custom stub at resources/stubs/seed.stub.
Thanks to @bahri-hirfanoglu for PR #222.
--noregister option: Generate seed files without adding them to DatabaseSeeder.php. Useful for creating backup seeders or manually managing which seeders are registered.php artisan iseed users --noregister
Thanks to @VukTodorovic for the original PR #230 (renamed from --noseed to --noregister for clearer semantics).
Small fixes and code quality improvements.
config() helper instead of \Config facade (#254) - @ChrisToxzhandle() method (#243) - @szepeviktorFull Changelog: https://github.com/orangehill/iseed/compare/v3.1.2...v3.1.3
Fixes #258 - php artisan iseed (without table names) now works on Laravel 11+.
Laravel 11 removed doctrine/dbal, so this release uses Laravel's Schema::getTables() facade instead.
Schema::getTables() for Laravel 11+ instead of doctrine/dbalThanks to @zackAJ for identifying the issue and initial implementation (#259)
Add Laravel 12 support
This release introduces significant improvements to the iSeed package functionality:
The tables argument is now optional in the iSeed command. When no specific tables are provided, the command will automatically generate seeders for all tables in your database.
php artisan iseed # Seeds all tables
php artisan iseed my_table # Seeds specific table
Filter the rows to be included in the seed file using the --where option:
# Filter by email domain
php artisan iseed users --where="email LIKE '%[@example](https://github.com/example).com'"
# Filter by date and status
php artisan iseed users --where="active = 1 AND created_at > '2024-01-01'"
# Complex filtering with additional options
php artisan iseed users --where="role = 'admin'" --max=10 --orderby=created_at --direction=desc
You can still use all existing features including:
php artisan iseed my_table,another_tablecomposer require orangehill/iseed
Adds Laravel 9 support.
Adds PHP8 support.
This release aims to add a native laravel 8 support. To do this the following changes were made:
Since some breaking changes were introduced, the version is bumped to a major release.
Added support for Laravel 8
Added Laravel 7.0 support
orderby and direction parametersAdded chunksize optional parameter which defines the size of data chunks for each insert query. Helps with issue described in https://github.com/orangehill/iseed/issues/4#issuecomment-380324859
Optionally specify a prefix or suffix for the Seeder class name and file name. This is useful if you want to create an additional seed for a table that has an existing seed without overwriting the existing one.
In order to support L55, the IseedCommand now has a handle() method for Laravel v5.5 and a fire() method for older Laravel versions.
https://github.com/laravel/framework/blob/master/CHANGELOG-5.5.md laravel/framework#19827 laravel/framework#20024
By using --orderby and --direction parameters you can now set the column which will be used for results ordering, and the direction to order by (ASC/DESC). This works great when you want to limit the number of exported database entries using the --max parameter.
By using --noindex the seed can be generated as a non-indexed array. The use case for this feature is when you need to merge two seed files.
Fixed a problem with query builder returning an object instead of an array.
Added prerun and postrun command options; Formatted code according to PSR-2 standard; Updated documentation.
Refactored code so that the package works with Laravel 5. If you want to use iSeed with Laravel 4, please use iSeed version 1.1.
How can I help you explore Laravel packages today?