/yii2-lazy-params

Simple and powerfull parameters for yii2 framework

Primary LanguagePHP

Yii2 lazy params

Yii2 zlay params

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist zlakomanoff/yii2-lazy-params "*"

or add

"zlakomanoff/yii2-lazy-params": "*"

to the require section of your composer.json file.

Usage

Simple config

'lp' => 'zlakomanoff\lazyparams\Component'

Simple usage

<?= Yii::$app->lp->get('option', 'default value') ?>

Advanced config

'lp' => [
    'class' => 'zlakomanoff\lazyparams\Component',
    'tableName' => 'dynamic_options',
    'keyColumn' => 'keyword',
    'valueColumn' => 'value',
    'liquidMode' => false,
    'enableCache' => false,
    'cacheDefaultValues' => false,
    'cacheComponent' => 'cache',
    'dbComponent' => 'db'
]

Advanced usage

echo Yii::$app->lp['param one'];
echo Yii::$app->lp['param two']['default value'];
echo Yii::$app->lp->paramThree('default value');
echo Yii::$app->lp->get('param four', 'default value');