andrylik / yii2-settings
Settings Manager for Yii2 with the possibility of translating values.
Package info
github.com/Andrylik/yii2-settings
Type:yii2-extension
pkg:composer/andrylik/yii2-settings
Requires
- creocoder/yii2-translateable: ^1.0
- yiisoft/yii2: ~2.0.10
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Yii2 Settings Extension
Settings Manager for Yii2 with the possibility of translating values.
Installation
Via Composer.
php composer.phar require --prefer-dist andrylik/yii2-settings "*"
Database Migrations
Before usage this extension, we'll also need to prepare the database.
php yii migrate --migrationPath=@vendor/andrylik/yii2-settings/migrations
Configuration
Module Setup
Configure "Yii2 Settings Extension" module in backend/config/main.php:
'modules' => [ 'settings' => [ 'class' => 'andrylik\settings\Module', ], ],
If you need to translate the values to other languages
add parameters in common/config/params.php
return [ // ... 'languages' => ['uk', 'ru', 'en'], //languages to translate 'defaultLanguage' => 'uk' //default app language ];
Also specify the language of the application common/config/main.php
return [ // ... 'language' => 'uk', //.. ];
Component Setup
Configure Settings Component common/config/main.php
'components' => [ 'cache' => [ 'class' => \yii\caching\FileCache::class, 'cachePath' => '@frontend/runtime/cache' ], 'settings' => [ 'class' => 'andrylik\settings\components\Settings', ], ],
Usage:
Go to http://backend.yourdomain.com/settings/default/index for managing your settings
Add a setting, for example, like this
Section: site
Key: default_title
Value: my super website
Description: default site title
Use the settings in your application
$settings = Yii::$app->settings; $title = $settings->get('site', 'default_title');