K
K
Kirill Djonua2015-02-04 16:47:04
Yii
Kirill Djonua, 2015-02-04 16:47:04

How to load configuration from database in Yii2?

An array with a global config is formed in the web.php file. It also has an event 'on beforeRequest', according to which the code is executed

Yii::$container->set(['key' => \app\models\Model::getValue()]);

where Model is yii\db\ActiveRecord
This config works fine as long as the \app\models\Model::tableName() table exists. However, when deploying the application on a new machine, a problem arises - until the migrations are applied, the required table does not exist yet - hence the yii\db\Exception is thrown.
How it is possible to configure a similar config correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksey Bernackiy, 2015-02-04
@usualdesigner

Check table existence by query builder in on beforeRequest

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question