iseed is a Laravel package that provides a method to generate a new seed file based on data from the existing database table.
This project was created by The EST Group and PHPHub.
You can refer to this documentation to know how to run this demo.
- Installation;
- Basic Usage;
- Recommend Usage;
- More Usage.
1). Require this package in your composer.json and update composer. This will download the package
composer require orangehill/iseed
2). After updating composer, add the ServiceProvider to the providers array in config/app.php
'providers' => [
...
Orangehill\Iseed\IseedServiceProvider::class,
],
Done. Very simple, isn't it? 🍻🍻🍻
Just run this command:
php artisan iseed users
It will be generate UsersTableSeeder.php
file.
You can also generate multiple seeder files at the same time, like:
php artisan iseed users,topics
it will be generate UsersTableSeeder.php
and TopicsTableSeeder.php
file.
Optional parameter which is used to automatically overwrite any existing seeds for desired tables.
php artisan iseed users --force
It will overwrite UsersTableSeeder.php
file.
The UsersTableSeeder.php
content is:
Optional parameter which specifies the DB connection name:
php artisan iseed users --database=mysql2
I advise you to use the package pack this way.
- Import production database into a developer's computer;
- The developer run
php artisan iseed ...
to generate the seeder files; - Submit all seeder files to the version management, then others can download the seeder files.
You can refer to the documentation to learn more about this package.
欢迎关注 LaravelTips
, 一个专注于为 Laravel 开发者服务, 致力于帮助开发者更好的掌握 Laravel 框架, 提升开发效率的微信公众号.