$this->createTable('example_table', [ 'id' => $this->primaryKey(), 'name' => $this->string(64)->notNull(), 'type' => $this->integer()->notNull()->defaultValue(10), 'description' => $this->text(), 'rule_name' => $this->string(64), 'data' => $this->text(), 'created_at' => $this->datetime()->notNull(), 'updated_at' => $this->datetime(), ]);
FileCache
could not write to the file, it will be visible in the logs.yii\web\ErrorAction
now shows 404, not a blank page in the case of a direct URL.yii migrate
refuses to work because of a missing directory, the path to it is shown in error.Json::encode()
and Json::decode()
better handle errors, throwing clear exceptions.ErrorHandler::logException()
now logs the entire object, not just its string representation. // $('#contact-form').yiiActiveForm('updateAttribute', 'contactform-subject', ["I have an error..."]); // $('#contact-form').yiiActiveForm('updateAttribute', 'contactform-subject', '');
$('#contact-form').yiiActiveForm('updateMessages', { 'contactform-subject': ['Really?'], 'contactform-email': ['I don\'t like it!'] }, true);
yii message
enhancements.pot
files is .pot
. Yii::t('app', 'There are new {messages} for you!', [ 'messages' => Html::a(Yii::t('app', 'messages'), ['user/notifications']), ]);
markUnused
option was added, which allows you to disable adding @@
to unused strings. class MyAsset extends AssetBundle { public $sourcePath = '@app/assets/js'; public $js = [ 'app.js', ]; public $depends = [ 'yii\web\YiiAsset', ]; public $publishOptions = [ 'except' => '*.ts', // exclude TypeScript sources // 'only' => '*.js', // include JavaScript only ]; }
web/assets
. This can be done directly from the application configuration: return [ // ... 'components' => [ 'assetManager' => [ 'hashCallback' => function ($path) { return hash('md4', $path); } ], ], ];
yii\web\DbSession
, but support may be extended in the future. For configuration, you need to change the configuration of the application: return [ // ... 'components' => [ 'session' => [ 'class' => 'yii\web\DbSession', 'readCallback' => function ($fields) { return [ 'expireDate' => Yii::$app->formatter->asDate($fields['expire']), ]; }, 'writeCallback' => function ($session) { return [ 'user_id' => Yii::$app->user->id, 'ip' => $_SERVER['REMOTE_ADDR'], 'is_trusted' => $session->get('is_trusted', false), ]; } ], ], ];
Source: https://habr.com/ru/post/264159/
All Articles