Codeception Object configuration must be an array - yii2
I am trying to run basic codeception test but what I get is the error bellow:
Backend\tests.functional Tests (1) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
E LoginCest: Login user (0.01s)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1) LoginCest: Login user
Test tests/functional/LoginCest.php:loginUser
[yii\base\InvalidConfigException] Object configuration must be an array containing a "class" element.
Scenario Steps:
1. $I->amOnPage("/admin/user/login") at tests/functional/LoginCest.php:18
#1 /home/projects/toma/toma-coreshop/vendor/yiisoft/yii2/BaseYii.php:353
#2 /home/projects/toma/toma-coreshop/vendor/yiisoft/yii2/base/Module.php:427
#3 /home/projects/toma/toma-coreshop/vendor/yiisoft/yii2/base/Module.php:586
#4 /home/projects/toma/toma-coreshop/vendor/yiisoft/yii2/base/Module.php:522
#5 /home/projects/toma/toma-coreshop/vendor/yiisoft/yii2/web/Application.php:103
#6 /home/projects/toma/toma-coreshop/vendor/symfony/browser-kit/Client.php:351
#7 Codeception\Lib\InnerBrowser->amOnPage
#8 /home/projects/toma/toma-coreshop/backend/tests/_support/_generated/FunctionalTesterActions.php:526
#9 /home/projects/toma/toma-coreshop/backend/tests/functional/LoginCest.php:18
#10 backend\tests\functional\LoginCest->loginUser
Time: 251 ms, Memory: 16.00MB
There was 1 error:
---------
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
The errors flows one by one on every step whit those tests. My configuration file looks like (backend\codeception.yml):
namespace: backend\tests
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Yii2:
configFile: 'config/test.php'
In my test.php I have:
<?php
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/main.php'),
require(__DIR__ . '/main-local.php'),
[
'id' => 'app-backend-test',
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=coreshop',
'username' => '*****',
'password' => '*****',
'charset' => 'utf8',
//'enableSchemaCache' => true,
],
]
]
);
return $config;
And finally my LoginCest.php:
/**
* Class LoginCest
*/
class LoginCest
{
/**
* #param FunctionalTester $I
*/
public function loginUser(FunctionalTester $I)
{
$I->amOnPage('/admin/user/login');
$I->fillField('Username', '***');
$I->fillField('Password', '***');
$I->click('Вход');
}
}
I followed the instruction given on the codeception site for the Yii2-advanced template. I am trying to test on old project so it is not newly installed Yii2-advanced if that matters in this case. Thank you!
EDIT
Main.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')
);
return [
'id' => 'app-backend',
'name' => 'Online Shop Admin',
'homeUrl' => '/admin',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'language' => 'bg-BG',
'bootstrap' => [
[
'class' => 'app\components\LanguageSelector',
'supportedLanguages' => [],
],
'log',
'devicedetect'
],
'modules' => [
'user' => [
'controllerMap' => [
'security' => 'backend\controllers\user\SecurityController',
'admin' => 'backend\controllers\user\AdminController',
],
'modelMap' => [
'User' => 'backend\models\User',
'SettingsForm' => 'backend\models\SettingsForm',
'Profile' => 'backend\models\Profile',
/*'UserSearch' => 'backend\models\UserSearch',*/
],
'rememberFor' => 1209600,
],
'statistics' => [
'class' => 'backend\modules\statistics\Module',
],
'catalogue' => [
'class' => 'backend\modules\catalogue\Module',
],
'news' => [
'class' => 'backend\modules\news\Module',
],
'sales' => [
'class' => 'backend\modules\sales\Module',
],
'wasteManagment' => [
'class' => 'backend\modules\wasteManagment\WasteManagment',
],
'help' => [
'class' => 'backend\modules\help\HelpInfo',
],
'marketing' => [
'class' => 'backend\modules\marketing\Module',
],
'translation' => [
'class' => 'backend\modules\translation\Module',
],
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.33.1'], // adjust this to your needs
'generators' => [
'crud' => [
'class' => 'backend\templates\crud_v1\Generator',
'templates' => ['mycrud' => '#backend/templates/crud_v1/default']
],
'model' => [
'class' => 'backend\templates\model_v1\Generator',
'templates' => ['mymodel' => '#backend/templates/model_v1/default']
],
/*'crud' => [
'class' => 'backend\templates\crud_module_v1\Generator',
'templates' => ['mycrudmodule' => '#backend/templates/crud_module_v1/default']
],
'model' => [
'class' => 'backend\templates\model_module_v1\Generator',
'templates' => ['mymodelmodule' => '#backend/templates/model_module_v1/default']
],*/
],
],
],
'components' => [
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'css' => [],
],
'yii\bootstrap\BootstrapPluginAsset' => [
'js' => []
],
'yii\web\JqueryAsset' => [
'js' => []
],
'wbraganca\dynamicform\DynamicFormAsset' => [
'js' => [
'/admin/dist/js/yii2-dynamic-form.js'
]
],
],
],
'urlManagerBackend' => [
'class' => 'yii\web\urlManager',
'baseUrl' => (isset($_SERVER['HTTPS']) ? "https" : 'http') . "://toma-coreshop.webbuild.com/admin",
'enablePrettyUrl' => true,
'showScriptName' => false,
],
'request' => [
'baseUrl' => '/admin',
'cookieValidationKey' => 'sew4789vb7834tvnv78',
'csrfParam' => '_backendCSRF',
],
'user' => [
'identityClass' => 'backend\models\User',
'enableAutoLogin' => true,
'loginUrl' => [ 'user/login'],
'identityCookie' => [
'name' => '_backendUser', // unique for backend
]
],
/*'session' => [
'name' => '_backendSessionId',
'savePath' => __DIR__ . '/../runtime/sessions',
],*/
'view' => [
'theme' => [
'pathMap' => [
'#dektrium/user/views' => '#backend/views/user',
'#dektrium/rbac/views' => '#backend/views/rbac',
],
],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
],
'translate' => [
'class' => 'backend\components\Translate'
],
'tabSettings' => [
'class' => 'backend\components\TabSettings'
],
'system' => [
'class' => 'backend\components\System'
],
'moneyConvertor' => [
'class' => 'backend\components\MoneyConvertor'
],
'moneyWords' => [
'class' => 'backend\components\MoneyWords'
],
'OutData' => [
'class' => 'backend\components\OutData'
],
'MakeURL' => [
'class' => 'backend\components\MakeURL'
],
'makeUrl' => [
'class' => 'frontend\components\MakeURL'
],
'image' => [
'class' => 'backend\components\Image'
],
'formatter' => [
'class' => 'yii\i18n\Formatter',
'nullDisplay' => '',
],
'devicedetect' => [
'class' => 'alexandernst\devicedetect\DeviceDetect'
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'profile' => 'user/settings/profile',
],
],
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'app' => 'app.php',
],
],
'help*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/help/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'help' => 'help.php',
],
],
'sales*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/sales/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'catalogue' => 'sales.php',
],
],
'statistics*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/statistics/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'catalogue' => 'statistics.php',
],
],
'catalogue*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/catalogue/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'catalogue' => 'catalogue.php',
],
],
'marketing*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/marketing/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'catalogue' => 'news.php',
],
],
'news*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/news/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'catalogue' => 'news.php',
],
],
'message*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/modules/translation/messages',
'sourceLanguage' => 'bg',
'fileMap' => [
'message' => 'message.php',
],
],
'kvgrid*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#backend/messages/kvgrid',
'sourceLanguage' => 'bg',
'fileMap' => [
'kvgrid' => 'kvgrid.php',
],
],
],
],
],
'params' => $params,
];
Main-local.php:
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'ud_6581BcmdaOC-RoK4LznBhsD7W4pyU',
],
],
'container' => [
'definitions' => [
kartik\grid\GridView::class => [
'krajeeDialogSettings' => ['overrideYiiConfirm' => false],
'responsiveWrap' => false,
'bordered' => false,
'tableOptions' => [
'class' => 'table full-color-table full-dark-table hover-table',
],
'resizableColumns' => true,
'hover' => true,
'layout' => "{items}\n{summary}\n{pager}",
'rowOptions' => function ($model) {
if(!empty($model->id))
return ['data-id' => $model->id];
else
return;
},
],
],
],
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['modules']['debug']['allowedIPs'] = ['*'];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
$config['modules']['gii']['allowedIPs'] = ['*'];
}
return $config;
Related
Update data in Kartik Detailview is not working
I've detail showed using Kartik Detail View. This widget has Edit inline function by clicking pencil icon button in top right side like this. But then the table doesn't be editable : And nothing happen, my data still the same, my update not success. It's possible to solve my problem? Thanks. I have read the official guide and it looks identical: https://demos.krajee.com/detail-view This is my view code: <?php echo DetailView::widget([ 'model' => $modelAnagrafiche, 'responsive' => true, 'mode' => 'edit', 'enableEditMode' => true, 'buttons1' => '{update}', 'panel' => [ 'type' => 'primary', 'heading' => 'Contratto' . ' : ' . $modelAnagrafiche >cognome_ragione_sociale . ' ' . $modelAnagrafiche->nome ], 'attributes' => [ [ 'group'=>true, 'label'=>'Sezione Anagrafica', 'rowOptions'=>['class'=>'table-primary'] ], [ 'columns' => [ [ 'attribute' => 'cognome_ragione_sociale', 'displayOnly' => true, 'valueColOptions' => ['style' => 'width:30%'] ], [ 'attribute' => 'nome', 'format' => 'raw', 'valueColOptions' => ['style' => 'width:30%'], 'displayOnly' => true, 'type' => DetailView::INPUT_TEXT, ], ], ], [ 'columns' => [ [ 'attribute' => 'codice_fiscale', 'displayOnly' => true, 'valueColOptions' => ['style' => 'width:30%'] ], [ 'attribute' => 'partita_iva', 'format' => 'raw', 'valueColOptions' => ['style' => 'width:30%'], 'displayOnly' => true ], ], ], [ 'columns' => [ [ 'attribute' => 'tipo_documento', 'displayOnly' => true, 'valueColOptions' => ['style' => 'width:30%'], 'format' => 'raw', 'value' => $modelAnagrafiche->tipoDocumento, ], [ 'attribute' => 'numero_documento', 'format' => 'raw', 'valueColOptions' => ['style' => 'width:30%'], 'displayOnly' => true ], ], ], [ 'columns' => [ [ 'attribute' => 'data_nascita', 'displayOnly' => true, 'format' => 'date', 'type' => DetailView::INPUT_DATE, 'widgetOptions' => [ 'pluginOptions' => ['format' => 'yyyy-mm-dd'] ], ], [ 'attribute' => 'id_provincia_nascita', 'displayOnly' => true, 'valueColOptions' => ['style' => 'width:30%'], 'format' => 'raw', 'value' => $modelAnagrafiche->provinciaNascitaNome, 'label' => 'Provincia Nascita' ], ], ], [ 'columns' => [ [ 'attribute' => 'id_comune_nascita', 'displayOnly' => true, 'format' => 'raw', 'value' => $modelAnagrafiche->comuneNascitaNome, 'label' => 'Comune Nascita' ], ], ], ], ]); ?> This is the action in my controller: public function actionUpdateAnagrafica() { $post = Yii::$app->request->post(); if (empty($post['Anagrafiche']['id'])) { throw new NotFoundHttpException('Non esiste nessuna anagrafica.'); } $modelAnagrafiche = Anagrafiche::findOne($post['Anagrafiche']['id']); if ($modelAnagrafiche->load($post) && $modelAnagrafiche->save()) { return $this->redirect(['view', 'id' => $modelAnagrafiche->id]); } else { return $this->render('update-anagrafica', [ 'modelAnagrafiche' => $modelAnagrafiche, ]); } }
You have to remove all the displayOnly attributes. According to the official guide: displayOnly: boolean|Closure, if the input is to be set to as display only in edit mode. If set to true, no editable form input will be displayed, instead this will display the formatted attribute value.
how to remove a column from export config
i am creating an export to excel configuration but i want to export some particular columns any idea?? 'exportConfig' => [ GridView::EXCEL => [ 'showHeader'=>$title, 'showFooter' => true, 'showCaption' => true, 'filename'=>$title.date("Ymd",strtotime($searchModel->start_date)), 'mime' => 'application/vnd.ms-excel', 'config' => [ 'worksheet' => 'ExportWorksheet', 'cssFile' => '' ] ], ], 'export'=>[ 'label'=>"Download", 'icon' =>'export', 'showConfirmAlert'=>false, 'target'=>GridView::TARGET_SELF, 'header'=>false ],
if you are using KartikGridView you could set the column you want to export in the GridView Widget 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'your_col1', 'your_col2', 'your_col3', .... ]; <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'showPageSummary' => true, 'exportConfig' => [ GridView::EXCEL => [ 'showHeader'=>$title, 'showFooter' => true, 'showCaption' => true, 'filename'=>$title.date("Ymd",strtotime($searchModel->start_date)), 'mime' => 'application/vnd.ms-excel', 'config' => [ 'worksheet' => 'ExportWorksheet', 'cssFile' => '' ] ], ], 'export'=>[ 'label'=>"Download", 'icon' =>'export', 'showConfirmAlert'=>false, 'target'=>GridView::TARGET_SELF, 'header'=>false ],
Eerror in social login in Yii2: Setting unknown property: yii\web\Application::authClientCollection
When I try to access app it get error after use yii2-authclient. I follow Facebook Authentication using Yii2 authclient All is setup, but this error occur: Setting unknown property: yii\web\Application::authClientCollection My frontend/main.php is: 'components' => [ 'request' => [ 'csrfParam' => '_csrf-frontend', ], 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true], ], 'session' => [ // this is the name of the session cookie used for login on the frontend 'name' => 'advanced-frontend', ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'errorHandler' => [ 'errorAction' => 'site/error', ], // 'urlManager' => [ // 'enablePrettyUrl' => true, // 'showScriptName' => false, // 'rules' => [ // ], // ], ], 'authClientCollection' => [ 'class' => 'yii\authclient\Collection', 'clients' => [ 'facebook' => [ 'class' => 'yii\authclient\clients\Facebook', 'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup', 'clientId' => '2061735130522390', 'clientSecret' => '2f302dc7358730820c091ca4444afbae', 'attributeNames' => ['name', 'email', 'first_name', 'last_name'], ], ], ], My site controller is: class SiteController extends Controller { /** * {#inheritdoc} */ public $successUrl = "success"; public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'only' => ['logout', 'signup'], 'rules' => [ [ 'actions' => ['signup'], 'allow' => true, 'roles' => ['?'], ], [ 'actions' => ['logout'], 'allow' => true, 'roles' => ['#'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } /** * {#inheritdoc} */ public function actions() { return [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, ], 'auth' => [ 'class' => 'yii\authclient\AuthAction', 'successCallback' => [$this, 'successCallback'], ], ]; } public function successCallback($client) { // get user data from client $userAttributes = $client->getUserAttributes(); $user = User::find()->where(['email'=>$userAttributes['email']])->one(); if (!empty($user)) { Yii::$app->user->login($user); } else{ $session = Yii::$app->session; $session['attribute'] = $userAttributes; $this->successUrl = Url::to(['signup']); } die(print_r($userAttributes)); // do some thing with user data. for example with $userAttributes['email'] } /** * Displays homepage. * * #return mixed */ public function actionIndex() { return $this->render('index'); } /** * Logs in a user. * * #return mixed */ . . . } login.php is: <div class="row"> <div class="col-lg-5"> <?php $form = ActiveForm::begin(['id' => 'login-form']); ?> <?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?> <?= $form->field($model, 'password')->passwordInput() ?> <?= $form->field($model, 'rememberMe')->checkbox() ?> <div style="color:#999;margin:1em 0"> If you forgot your password you can <?= Html::a('reset it', ['site/request-password-reset']) ?>. </div> <div class="form-group"> <?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> </div> <p>OR</p> <?= yii\authclient\widgets\AuthChoice::widget([ 'baseAuthUrl' => ['site/auth'] ]) ?> <?php ActiveForm::end(); ?> </div> </div>
Your config is incorrect, authClientCollection config should be inside of components array - in your case it is outside of it. You should move authClientCollection element one line up and change this: ], 'authClientCollection' => [ 'class' => 'yii\authclient\Collection', 'clients' => [ 'facebook' => [ 'class' => 'yii\authclient\clients\Facebook', 'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup', 'clientId' => '2061735130522390', 'clientSecret' => '2f302dc7358730820c091ca4444afbae', 'attributeNames' => ['name', 'email', 'first_name', 'last_name'], ], ], ], To this: 'authClientCollection' => [ 'class' => 'yii\authclient\Collection', 'clients' => [ 'facebook' => [ 'class' => 'yii\authclient\clients\Facebook', 'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup', 'clientId' => '2061735130522390', 'clientSecret' => '2f302dc7358730820c091ca4444afbae', 'attributeNames' => ['name', 'email', 'first_name', 'last_name'], ], ], ], ],
PendalF89/yii2-filemanager upload error. (Call to a member function saveAs() on null)
getting Call to a member function saveAs() on null error from ajax request while uploading image via filemanager. Config: ... 'modules' => [ 'site' => [ 'class' => 'app\modules\site\Module', ], 'user' => [ 'class' => 'app\modules\user\Module', 'controllerNamespace' => 'app\modules\user\controllers\frontend', 'viewPath' => '#app/modules/user/views/frontend', ], 'admin' => [ 'class' => 'app\modules\admin\Module', 'layout' => '#app/views/layouts/admin', 'modules' => [ 'user' => [ 'class' => 'app\modules\user\Module', 'controllerNamespace' => 'app\modules\user\controllers\backend', 'viewPath' => '#app/modules/user/views/backend', ], 'pages' => [ 'class' => 'bupy7\pages\Module', 'controllerNamespace' => 'bupy7\pages\controllers\backend', 'controllerMap' => [ 'manager' => [ 'class' => 'bupy7\pages\controllers\backend\ManagerController', ], ], ], 'gallery' => [ 'class' => 'sadovojav\gallery\Module', 'basePath' => '#webroot/galleries', ], 'filemanager' => [ 'class' => 'pendalf89\filemanager\Module', // Upload routes 'routes' => [ // Base absolute path to web directory 'baseUrl' => '', // Base web directory url 'basePath' => '#webroot', // Path for uploaded files in web directory 'uploadPath' => 'uploads', ], // Thumbnails info 'thumbs' => [ 'small' => [ 'name' => 'Small', 'size' => [100, 100], ], 'medium' => [ 'name' => 'Medium', 'size' => [300, 200], ], 'large' => [ 'name' => 'Big', 'size' => [500, 400], ], ], ], ], ], ... actionUpload() in Controller public function actionUpload() { $model = new Mediafile(); $routes = $this->module->routes; $rename = $this->module->rename; $model->saveUploadedFile($routes, $rename); Yii::$app->response->format = Response::FORMAT_JSON; $tagIds = Yii::$app->request->post('tagIds'); if ($tagIds !== 'undefined') { $model->setTagIds(explode(',', $tagIds)); } $bundle = FilemanagerAsset::register($this->view); if ($model->isImage()) { $model->createThumbs($routes, $this->module->thumbs); } $response['files'][] = [ 'url' => $model->url, 'thumbnailUrl' => $model->getDefaultThumbUrl($bundle->baseUrl), 'name' => $model->filename, 'type' => $model->type, 'size' => $model->file->size, 'deleteUrl' => Url::to(['file/delete', 'id' => $model->id]), 'deleteType' => 'POST', ]; return $response; } Checked in the model, $this->file = UploadedFile::getInstance($this, 'file'); in saveUploadedFile() returns null instead of object. The problem is that the function saveUploadedFile() is been executed, the file is saved and the record is created in the database, but it returns error.
Log not working in yii2
i want to put a log in app.log ,My config file 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ 'file' => [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], 'logFile' => '#root/console/runtime/logs/app.log', ], ] ] in controller action public function actionRankCalculation() { $allConest = Contest::find()->where('isActive = 1')->all(); Yii::trace('start calculating average revenue'); $response = []; /** #var Contest $contest */ foreach ($allConest as $contest) { $videoQuery = Video::find()->where('contest_id = ' . $contest->id); $videoQuery->andWhere('isActive = 1'); $videoQuery->orderBy([ 'global_likes' => SORT_DESC, 'id' => SORT_ASC, ]); } But Yii::trace('start calculating average revenue'); not working
You try this.Use categories. For example like below 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error'], 'categories' => ['test1'], 'logFile' => '#app/Test/test1.log', ], And use below one in controller action public function actionIndex(){ Yii::error('Test index action', $category = 'test1'); }
Try to set both flushInterval and exportInterval to 1 in console config: return [ 'bootstrap' => ['log'], 'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'exportInterval' => 1, ], ], 'flushInterval' => 1, ], ], ]; It makes each log message appearing immediately in logs.