PHP code example of demmonico / yii2-config

1. Go to this page and download the library: Download demmonico/yii2-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

demmonico / yii2-config example snippets


composer 

"demmonico/yii2-config": "*"

return [
    //...
    'components' => [
        //...
        'config' => 'demmonico\config\Configurator',
    ],
];

return [
    //...
    'components' => [
        //...
        'config' => [
            'class' => 'demmonico\config\Configurator',
            'tableName' => 'tbl_config',
            'defaultConfigFile' => '@common/data/default.php',
        ],
    ],
];

return [
    //...
    'components' => [
        //...
        'config' => [
            //...
            'handler' => [
                'class' => 'testHandler',
                'config'=> [
                    'fileStorage' => 'missing_configs',
                    'folderStorage' => '@common/data/',
                ],
            ],
        ],
    ],
];

\Yii::$app->config->get('paramName');

\Yii::$app->config->get('paramName', 'defaultValue');

\Yii::$app->config->getLike('beginParamName');

\Yii::$app->config->getLike('someModule');

\Yii::$app->config->app('paramName');

\Yii::$app->config->app('name');

// ...
'sms' => [
    'class' => 'demmonico\sms\Sender',
    'senderNumber' => [
        'component' => 'config',
        'sms.senderNumber' => 'AppName',
    ],
],

return [
    // ...
    'bootstrap' => [..., 'config', ...],
    // ...
],

return [
    //...
    'components' => [
        //...
        'config' => [
            //...
            'bootstrap' => [
                'cloudStorage' => [
                    'key' => 'cloud_amazons3_key',
                    'secret' => 'cloud_amazons3_secret',
                    'bucket' => 'cloud_amazons3_bucket',
                    'cloudStorageBaseUrl' => 'cloud_amazons3_baseurl',
                ],
                'upload' => [
                    'externalStorageBaseUrl' => 'cloud_amazons3_baseurl',
                ],
            ],
        ],
    ],
];

\Yii::$app->template->get('templateName');

\Yii::$app->template->get('templateName', ['param1' => 'value1', 'param2' => 'value2']);

\Yii::$app->setTemplate('email_key')->setTo('email')->send();

\Yii::$app->email
    ->setTemplate('test-html.php')
    ->setTo('[email protected]')
    ->setFrom('admin@localhost')
    ->setSubject('Your account on ' . $appName)
    ->setParams(['user' => $this, 'appName' => $appName])
    ->send();