I installed yii faker
"yiisoft/yii2-faker": "*"
advanced template
console/config/main.php:
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
Yii::setAlias('tests', __DIR__ . '/../tests');
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'modules' => [],
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
],
'params' => $params,
'controllerMap' => [
'fixture' => [
'class' => 'yii\faker\FixtureController',
],
],
];
console/tests/unit/templates/fixtures/pages.php
<?php
return [
[
'title' => 'word',
'content' => function ($fixture, $faker, $index) {
//set needed fixture fields based on different conditions
$fixture['content'] = $faker->sentence(7,true); //generate sentence exact with 7 words.
return $fixture;
}
],
];
run in console:
yii fixture/generate pages
I get this error:
How can I copy errors from the console?
Also, how can I add the generated data to my pages table?