PHPackages                             antonyz89/yii2-seeder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. antonyz89/yii2-seeder

ActiveYii2-extension[Database &amp; ORM](/categories/database)

antonyz89/yii2-seeder
=====================

A tool to quickly populate database with fake data

1.3.4(2y ago)627.9k↓37%4[1 issues](https://github.com/AntonyZ89/yii2-seeder/issues)2BSD-3-ClausePHPPHP &gt;=7.0

Since Feb 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AntonyZ89/yii2-seeder)[ Packagist](https://packagist.org/packages/antonyz89/yii2-seeder)[ RSS](/packages/antonyz89-yii2-seeder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (10)Used By (2)

yii2-seeder
===========

[](#yii2-seeder)

[ ![Donate with PayPal](https://camo.githubusercontent.com/648ad6f048733f167bf65e11a4fd759eef14da88db61ad078bbd5ddea5d57133/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e6174655f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YATHVT293SXDL&source=url)\--

[![Latest Stable Version](https://camo.githubusercontent.com/b9f192ddb3b1cc5c405151268cbd91285dabd3190690ef42971d6be408bcff4a/68747470733a2f2f706f7365722e707567782e6f72672f616e746f6e797a38392f796969322d7365656465722f762f737461626c65)](https://packagist.org/packages/antonyz89/yii2-seeder)[![Total Downloads](https://camo.githubusercontent.com/b1b2da242b2529eb1796ef8bc6d1855a1c79c01f2983b6c4252ddc324e6591a6/68747470733a2f2f706f7365722e707567782e6f72672f616e746f6e797a38392f796969322d7365656465722f646f776e6c6f616473)](https://packagist.org/packages/antonyz89/yii2-seeder)[![Latest Unstable Version](https://camo.githubusercontent.com/710d3429301a0c169e819ccfc3b9588dd8331d807ba8f7fa437e16a3f708babd/68747470733a2f2f706f7365722e707567782e6f72672f616e746f6e797a38392f796969322d7365656465722f762f756e737461626c65)](https://packagist.org/packages/antonyz89/yii2-seeder)[![License](https://camo.githubusercontent.com/8d2ed8e34bb120a8c41e6e7b8e7b28fbf538ba1a90f639c377c10c0a335fef06/68747470733a2f2f706f7365722e707567782e6f72672f616e746f6e797a38392f796969322d7365656465722f6c6963656e7365)](https://packagist.org/packages/antonyz89/yii2-seeder)

- [Installation](#installation)
- [Usage](#usage)
- [Seeder Commands](#seeder-commands)
- [Seeder Template](#seeder)
- [DatabaseSeeder Class](#databaseseeder)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist antonyz89/yii2-seeder dev-master

```

or add

```
"antonyz89/yii2-seeder": "dev-master"

```

to the require section of your `composer.json` file.

USAGE
-----

[](#usage)

**console/config/main.php**

```
'controllerMap' => [
    'seeder' => [
        'class' => 'antonyz89\seeder\SeederController'
    ],
],

```

SEEDER COMMANDS
---------------

[](#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

- `name` without TableSeeder (e.g `yii seeder user` for `UserTableSeeder`)

`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
------

[](#seeder)

**EXAMPLE TEMPLATE**

```
