How to Seed yii2 Database

Hi all,

Do you know whether there is some way of doing to seed yii2 database ?

With Laravel I do just a command to create seeder classes, write som code in its (with Faker Library for instance) and run it in Console.

I’m unable to see any documentation on this possibility in Yii2

Is there ?

Thanks

I get a Error: The template path "@tests/unit/templates/fixtures" does not exist

And I’m stuck with that

I set the alias in console bootstrap.php

I provide Fixture class in myApp/tests/unit/templates/fixtures/DogFixture.php

And I provide fixtures data in myApp/tests/unit/templates/fixtures/data/dog.php

Too much complicated in regards with others framework seeder/fixtures process

There is something missing !!!!

I set up fixtures on fresh yii2 BASIC app

But always unable to do it on ADVANCED app

In my composer, for both ot those app, i use faker.

No problem on BASIC app, but on ADVANCED app there is a message coming from Faker that saids @tests/unit/templates/fixtures

1- why fixtures path shoud be different to the one for Basic app (test/unit/fixtures)

2- when i set up a such path (with good namespace on it for DogFixture class) then ALWAYS same message

Does someone set up correctly this ADVANCED app for fixture ?

Is is a bug

Any help would be appreciate

Thx

You have to set up in common/config/main.php the alias @tests

Then you have to create a tests/templates/fixtures path