Yii2 Faker with kartikadvanced app not working

Hey Yii2 Team,

thanks for the nice work you put into the framework.

But somehow i cant generate demo data.

i have this layout: /console/tests/unit/templates/fixutres/user.php which just contains:

return [

    'username' => $faker->userName,

    'auth_key' => Yii::$app->getSecurity()->generateRandomString(),

    'password_hash' => Yii::$app->getSecurity()->generatePasswordHash('password_' . $index),

    'email' => $faker->email,

    'role' => 10,

    'status' => 1,

    'created_at' => $faker->unixTime($max = 'now'),

    'updated_at' => $faker->unixTime($max = 'now'),


and in my console/config/main.php i added

Yii::setAlias('tests', dirname(dirname(__DIR__)) . '/console/tests');

runnning gii fixtures/generate gives me this:

max@Dell:/var/www/professionalworks/src$ ./yii fixture/generate user

Fixtures will be generated under the path: 


Templates will be taken from path: 


	* user

Generate above fixtures? (yes|no) [no]:yes

The following fixtures template files were generated:

	* user

now i have the data generated under /unit/fixtures/data/user.php:


return [


        'username' => 'schaefer.kaitlyn',

        'auth_key' => 'QTVYTZ9afHdYqE2d4OIalqwegiD-3nFs',

        'password_hash' => '$2y$13$ipatHgHnxP0fobVAac44fevbow/Se.7nlzkyEbwBvTQhAQQ3KbgRq',

        'email' => 'david21@shanahanstrosin.com',

        'role' => 10,

        'status' => 1,

        'created_at' => 618287548,

        'updated_at' => 1295739757,



        'username' => 'bailey.georgiana',

        'auth_key' => 'cjwBETKVeSd4LO-nzcfkJghLFojI7eY5',

        'password_hash' => '$2y$13$th5SiGxOqA1QmXL8ndtAquRZB79kV3V8QIp9oexElVmRxcugRlQKO',

        'email' => 'mohr.michele@hotmail.com',

        'role' => 10,

        'status' => 1,

        'created_at' => 901388457,

        'updated_at' => 1032001226,



and i created an UserFixture.php File in fixtures dir containing this:


namespace console\tests\unit\fixtures;

use yii\test\ActiveFixture;

class UserFixture extends ActiveFixture {

    public $modelClass = 'common\models\User';


now if i try to fill the db table with data i get this:

max@Dell:/var/www/professionalworks/src$ ./yii fixture/load user

Some fixtures were not found under path:


Check that they have correct namespace "tests\unit\fixtures" 

	1. user

Error: No files were found by name: "user".

Check that files with these name exists, under fixtures path: 




had a name issue! now i can run the command without errror:

max@Dell:/var/www/professionalworks/src$ ./yii fixture/load User

Fixtures namespace is: 


Global fixtures will be used:

	1. yii\test\InitDb

Fixtures below will be loaded:

	1. User

Load above fixtures? (yes|no) [no]:yes

Fixtures were successfully loaded from namespace:


	1. yii\test\InitDbFixture

	2. tests\unit\fixtures\UserFixture


but no user entries were generated in the db…!

any idea why? any help?

thanks max

Having the same problem.

Anybody has a solution for this ?

I am also Having the same problem.

Anybody has a solution for this ?

I have the same issue, maybe open a github issue?

I solved this problem changing the name of file generated under “tests/unit/fixtures/data/” folder. I put the same name of User’s table. For more details, debug the line 99 from the class yii\testActiveFixture.