Yii Framework Forum: Yii1 database seeder - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii1 database seeder

#1 User is offline   tebazil 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 19-December 12
  • Location:Russia

Posted 16 October 2015 - 04:47 PM

The Yii1 database seeder extension is now released!

Built with simplicity in mind, it brings you ability to fill your database with (mainly) Faker data by quickly configuring relations between the tables and columns of your tables and corresponding generators of fake data.

Have a look at how simple and straightforward the usage is:

$seeder = new \tebazil\yii1seeder\Seeder();
$generator = $seeder->getGeneratorConfigurator();
$faker = $generator->getFakerConfigurator();

$seeder->table('article')->columns([
    'id', //automatic pk
    'book_id', //automatic fk
    'name'=>$faker->firstName,
    'content'=>$faker->text
        ])->rowQuantity(30);


$seeder->table('book')->columns([
    'id',
    'name'=>$faker->text(20),
])->rowQuantity(30);

//etc...

$seeder->refill(); 


You can locate the code above in a console command to call it when you need your test data to be refreshed.
Here is the Yii1 extension. The framework-agnostic database seeding library is also available.

You are welcome to comment on my work and suggest improvements.

Thanks for your attention.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users