Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrylik/yii2-settings
Yii2 setting manager
https://github.com/andrylik/yii2-settings
yii2 yii2-extension yii2-settings yii2-settings-module yii2-settings-translate
Last synced: 10 days ago
JSON representation
Yii2 setting manager
- Host: GitHub
- URL: https://github.com/andrylik/yii2-settings
- Owner: Andrylik
- License: mit
- Created: 2023-12-24T15:33:09.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-24T15:35:00.000Z (11 months ago)
- Last Synced: 2024-10-11T21:42:21.708Z (about 1 month ago)
- Topics: yii2, yii2-extension, yii2-settings, yii2-settings-module, yii2-settings-translate
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Yii2 Settings Extension
Settings Manager for Yii2 with the possibility of translating values.
Installation
------------Via [Composer](http://getcomposer.org/download/).
```sh
php composer.phar require --prefer-dist andrylik/yii2-settings "*"
```
**Database Migrations**Before usage this extension, we'll also need to prepare the database.
```sh
php yii migrate --migrationPath=@vendor/andrylik/yii2-settings/migrations
```Configuration
-------------
**Module Setup**Configure "Yii2 Settings Extension" module in ```backend/config/main.php```:
```php
'modules' => [
'settings' => [
'class' => 'andrylik\settings\Module',
],
],
```If you need to translate the values to other languages
add parameters in ```common/config/params.php```
```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```
```php
return [
// ...
'language' => 'uk',
//..
];
```**Component Setup**
Configure Settings Component ```common/config/main.php```
```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``` for managing your settings
Use the settings in your application
```php
$settings = Yii::$app->settings;$value = $settings->get('section', 'key');
```