dev-master
9999999-devSimple yii2 component for persistent settings storage
MIT
The Requires
by Oles Savluk
Simple yii2 component for persistent settings storage
Simple yii2 component for persistent settings storage, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require olessavluk/yii2-settings "*@dev"
, (*4)
or add, (*5)
"olessavluk/yii2-settings": "*@dev"
, (*6)
to your composer.json
file., (*7)
Add migration to create table for settings:, (*8)
class m150929_124601_settings extends olessavluk\settings\m150929_122401_settings { }
Add the following code in your application configuration:, (*9)
'components' => [ ... /** * required for advanced application template, * to share cache between frontend and backend */ 'frontCache' => [ 'class' => 'yii\caching\FileCache', 'cachePath' => '@frontend/runtime/cache', ], 'settings' => [ 'class' => '\olessavluk\settings\SettingsComponent', 'cacheName' => 'frontCache', 'defaults' => [ //optional default settings 'app' => [ 'siteName' => 'MyApp', 'adminEmail' => 'admin@exapmle.com', 'fromEmail' => 'no-reply@example.com', ], ], ], ... ]
Now you can use this component:, (*10)
Yii->$app->settings->get('app', 'siteName'); Yii->$app->settings->delete('app', 'siteName'); Yii->$app->settings->set('app', 'siteName', 'NewSiteName');
Simple yii2 component for persistent settings storage
MIT