Posts Tagged with Yii2 error

Displaying 1-2 of 2 results.
Resolved: Yii 2.0.12.2 advanced ./yii(php yii) console throw error Exception yii\base\UnknownPropertyException
posted by admin on October 13, 2018
Yii2 advanced
common main.php config

<?php

return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@common/messages',
],
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@common/messages',
],
],
],
'assetManager' => [
'appendTimestamp' => true,
'linkAssets' => true,
],
'request' => [
//'enableCookieValidation' => true,
//'enableCsrfValidation' => true,
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
],
],
'on beforeAction' => function ($event) {
//to do
},
];

command line comand in yii2 project directory

arthur@smart:/var/www/smartsuccess/html$ php yii


Throw error

Exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: yii\console\Request::parsers'

in /var/www/smartsuccess/html/vendor/yiisoft/yii2/base/Component.php:201

Stack trace:
#0 /var/www/smartsuccess/html/vendor/yiisoft/yii2/BaseYii.php(529): yii\base\Component->__set('parsers', Array)
#1 /var/www/smartsuccess/html/vendor/yiisoft/yii2/base/Object.php(105): yii\BaseYii::configure(Object(yii\console\Request), Array)
#2 [internal function]: yii\base\Object->__construct(Array)
#3 /var/www/smartsuccess/html/vendor/yiisoft/yii2/di/Container.php(381): ReflectionClass->newInstanceArgs(Array)
#4 /var/www/smartsuccess/html/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('yii\\console\\Req...', Array, Array)
#5 /var/www/smartsuccess/html/vendor/yiisoft/yii2/BaseYii.php(348): yii\di\Container->get('yii\\console\\Req...', Array, Array)
#6 /var/www/smartsuccess/html/vendor/yiisoft/yii2/di/ServiceLocator.php(135): yii\BaseYii::createObject(Array)
#7 /var/www/smartsuccess/html/vendor/yiisoft/yii2/console/Application.php(219): yii\di\ServiceLocator->get('request')
#8 /var/www/smartsuccess/html/vendor/yiisoft/yii2/base/Application.php(380): yii\console\Application->getRequest()
#9 /var/www/smartsuccess/html/yii(27): yii\base\Application->run()
#10 {main}

Read more
Resolved: Yii2 The 'label' option is required NavBar
posted by admin on February 21, 2017

<?php
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use app\helpers\App;
use yii\helpers\Html;

NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => App::t('Home'), 'url' => ['/site/index']],
//['label' => 'About', 'url' => ['/site/about']],
//['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ? (
['label' => App::t('Sign up', 'app2'), 'url' => ['/site/registration']]
) : (
[]
),
Yii::$app->user->isGuest ? (
['label' => App::t('Login'), 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
App::t('Logout').' (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
),

],
]);
NavBar::end();
?>
Read more