M
M
Monitorkin2017-07-11 19:24:56
Yii
Monitorkin, 2017-07-11 19:24:56

How to transfer params.php to a module?

How to transfer config\params.php to a module and take parameters from there in the module?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
paldraken, 2017-07-11
@Monitorkin

In the documentation for modules, just the example you need
www.yiiframework.com/doc-2.0/guide-structure-modul...

namespace app\modules\forum;

class Module extends \yii\base\Module
{
    public function init()
    {
        parent::init();
        // initialize the module with the configuration loaded from config.php
        \Yii::configure($this, require(__DIR__ . '/config.php'));
    }
}

config.php
<?php
return [
    'components' => [
        // list of component configurations
    ],
    'params' => [
        // list of parameters
    ],
];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question