PHPackages                             tebazil/yii2-db-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. tebazil/yii2-db-seeder

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

tebazil/yii2-db-seeder
======================

Yii2 adapter for PHP Database Seeder library

0.0.0(10y ago)3388.2k↓39.5%1[2 issues](https://github.com/tebazil/yii2-db-seeder/issues)BSD-3-ClausePHP

Since Oct 11Pushed 10y ago3 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

Yii2 Db Seeder
==============

[](#yii2-db-seeder)

Yii2 Db seeder is a Yii2 adapter for [Php db seeder](http://github.com/tebazil/db-seeder), which is a tool to quickly populate database with fake data.

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

[](#installation)

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

Either run

```
$ composer require tebazil/yii2-db-seeder
```

or add

```
"tebazil/yii2-db-seeder": "*"

```

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

Quick start
-----------

[](#quick-start)

You can quickly seed your database with generated data with something like this:

```
$seeder = new \tebazil\yii2seeder\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);

$seeder->table('category')->columns([
    'id',
    'book_id',
    'name'=>$faker->text(20),
    'type'=>$faker->randomElement(['shop','cv','test']),
])->rowQuantity(30);

$seeder->refill();
```

Please review the [Php db seeder](http://github.com/tebazil/db-seeder) for extended documentation on usage.

Differences from original library
---------------------------------

[](#differences-from-original-library)

- With `Yii2 Db Seeder` you do not need to provide database configuration by default, it uses `Yii::$app->db` to retrieve connection information. You can optionally provide seeder with a database connection component name. You do that like:

```
$seeder = new \tebazil\yii2seeder\Seeder('db2');
```

There. Seeder would be using `Yii::$app->db2` now.

- You can use standart yii wildcards for prefixed table names, like `{{%table_name}}`.
- `yii\db\Migration` is used as a database abstraction layer instead of a native database helper. This basically means that you can work with all the databases Yii2 supports.

Best usage practices
--------------------

[](#best-usage-practices)

- Create your project's database, generate some models and crud with gii.
- Make a console application controller for action refilling database with test data.
- Run it when it is needed

=&gt; You have project with test data in your database, easier to develop and easier to show to clients what's being happening

---

- If you use migrations, don't be confused with the fact that migrations keep the project history, and `db-seeder` is not bound to them - migrations and seeding are two different instruments. Migrations is a long-term instrument to manipulate database structure with time keeping history, and database seeder is a simple library to keep test data up-to-date. So, when a new migration appears, just fix the console command filling the database to be up-to-date.
- On early project develoment stages, the tool is useful when being run every time a commit happens, happening immediately after migrations are applied
- On later project development stages constant test data refilling might ruin the testing, so the advice would be to refill manually and only the tables you need (usually the newly created ones - to test out new things)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3872d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c53a3bd47504ecf015853565657a1d1b129a392c88ed5d324f0544801baa2f3?d=identicon)[tebazil](/maintainers/tebazil)

---

Top Contributors

[![vambus](https://avatars.githubusercontent.com/u/2419721?v=4)](https://github.com/vambus "vambus (7 commits)")

### Embed Badge

![Health badge](/badges/tebazil-yii2-db-seeder/health.svg)

```
[![Health](https://phpackages.com/badges/tebazil-yii2-db-seeder/health.svg)](https://phpackages.com/packages/tebazil-yii2-db-seeder)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
