Download the PHP package antonyz89/yii2-seeder without Composer
On this page you can find all versions of the php package antonyz89/yii2-seeder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download antonyz89/yii2-seeder
More information about antonyz89/yii2-seeder
Files in antonyz89/yii2-seeder
Package yii2-seeder
Short Description A tool to quickly populate database with fake data
License BSD-3-Clause
Informations about the package yii2-seeder
yii2-seeder
--
- Installation
- Usage
- Seeder Commands
- Seeder Template
- DatabaseSeeder Class
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json file.
USAGE
console/config/main.php
SEEDER COMMANDS
yii seeder Seed all tables in Database::run()
yii seeder [name] Seed a table
yii seeder [name]:[funtion_name] Seed a table and run a specific function from selected TableSeeder
namewithout TableSeeder (e.gyii seeder userforUserTableSeeder)
yii seeder/create model_name Create a TableSeeder in console\seeder\tables
For seeder, if the model is not at the root of the common/models, just add the folder where the model is located inside the common/models directory.
Example:
yii seeder/create entity/user
entity is the folder where User (model) is located inside the common/models directory.
To change the default path for models, just change the $modelNamespace variable in SeederController
Only Seeders within DatabaseSeeder::run() will be used in yii seeder command
SEEDER
EXAMPLE TEMPLATE
By default, all TableSeeder truncate the table before inserting new data, if you didn't want that to happen in a Seeder, just overwrite $skipTruncateTables:
default in TableSeeder:
At the end of every Seeder, if any columns have been forgotten, a message with all the missing columns will appear
DatabaseSeeder
DatabaseSeeder will be created on first yii seeder/create model
Here you will put all TableSeeder in ::run()
to run, use yii seeder or yii seeder [name]
namewithout TableSeeder (e.gyii seeder userforUserTableSeeder)
DatabaseSeeder template:
DatabaseSeeder localization is console\seeder
All versions of yii2-seeder with dependencies
ext-mbstring Version *
yiisoft/yii2 Version ^2.0.5
yiisoft/yii2-faker Version *
yiibr/yii2-br-validator Version ^1.0