dev-master
9999999-devFill your database table with fake data
MIT
The Requires
by Dmitry MiksIr
1.0.1
1.0.1.0Fill your database table with fake data
MIT
The Requires
by Dmitry MiksIr
Wallogit.com
2017 © Pedro Peláez
Fill your database table with fake data
This Yii2 command can fill your database with fake data. Useful if you need lot of fake data, 1 mil rows and more., (*1)
You can switch between different data generators (or write your own) and different database connectors., (*2)
Props: - you can write own sources of fake data (proxy to fzaninotto/Faker included) - different connectors to datbase for save data. ActiveRecord - slow but with model logic, YiiDAO - fast batch insert, TODO: postgresql COPY connector., (*3)
Generators included:
- FakeGenerator: this is proxy to Faker
and use same logic, paths and templates as yii2-faker . Read yii2-faker
documentation about creating fixtures template file, (*4)
Database connectors (called here as dbproviders): - Csv: simple csv writer - ActiveRecord: create model, fill with data and call ->save() - YiiDAO: insert data using sql (via Yii's PDO), can insert multiple rows per one insert, (*5)
Use composer :), (*6)
composer require miksir/yii2-db-faker
You should configure your application as follows (usually in console.php; and you can use any alias, not only "faker"):, (*7)
'controllerMap' => [
'faker' => [
'class' => 'MiksIr\Yii2DbFaker\FakerController',
],
],
Call help for current generator and dbprovider, (*8)
yii faker/help
yii faker/generate --count=1000000 --dbprovider=YiiDAO generator_template=users dbprovider_table=users dbprovider_truncate=1
Truncate table users and create about 1 million rows using template from \@tests/unit/templates/fixtures/users.php, (*9)
Fill your database table with fake data
MIT
Fill your database table with fake data
MIT