2017 © Pedro Peláez
 

yii2-extension yii2-settings

Yii2 Settings Module

image

yii2mod/yii2-settings

Yii2 Settings Module

  • Saturday, March 3, 2018
  • by disem
  • Repository
  • 7 Watchers
  • 69 Stars
  • 10,997 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 21 Forks
  • 0 Open issues
  • 24 Versions
  • 11 % Grown

The README.md

, (*1)

Yii2 Settings Extension


Persistent, application-wide settings for Yii2., (*2)

Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality, (*3)

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff., (*4)

Installation

The preferred way to install this extension is through composer., (*5)

Either run, (*6)

php composer.phar require --prefer-dist yii2mod/yii2-settings "*"

or add, (*7)

"yii2mod/yii2-settings": "*"

to the require section of your composer.json., (*8)

Configuration

Database Migrations, (*9)

Before usage this extension, we'll also need to prepare the database., (*10)

php yii migrate --migrationPath=@vendor/yii2mod/yii2-settings/migrations

Module Setup, (*11)

To access the module, you need to configure the modules array in your application configuration:, (*12)

'modules' => [
    'settings' => [
        'class' => 'yii2mod\settings\Module',
    ],
],

You can then access settings management section through the following URL:, (*13)

http://localhost/path/to/index.php?r=settings

or if you have enabled pretty URLs, you may use the following URL:, (*14)

http://localhost/path/to/index.php/settings

Component Setup, (*15)

To use the Setting Component, you need to configure the components array in your application configuration:, (*16)

'components' => [
    'settings' => [
        'class' => 'yii2mod\settings\components\Settings',
    ],
],

Usage:

$settings = Yii::$app->settings;

$value = $settings->get('section', 'key');

$settings->set('section', 'key', 125.5);

$settings->set('section', 'key', 'false', SettingType::BOOLEAN_TYPE);

// Checking existence of setting
$settings->has('section', 'key');

// Activates a setting
$settings->activate('section', 'key');

// Deactivates a setting
$settings->deactivate('section', 'key');

// Removes a setting
$settings->remove('section', 'key');

// Removes all settings
$settings->removeAll();

// Get's all values in the specific section.
$settings->getAllBySection('section');

$settings->invalidateCache(); // automatically called on set(), remove();

Manage custom settings

You can use your own form model to manage custom settings for your web application via SettingsAction. To use the SettingsAction class you need to follow the following steps:, (*17)

1) Create your own model, for example:, (*18)

 Yii::t('app', 'Application Name'),
            'adminEmail' => Yii::t('app', 'Admin Email'),
        ];
    }
}
```

2) Create view file, named `settings.php` with the following content:

```php
title = Yii::t('app', 'Manage Application Settings');
?>


field($model, 'appName'); ?>

field($model, 'adminEmail'); ?>

 'btn btn-success']) ?>



3) Add settings action to your controller class as follows:, (*19)

<?php

namespace app\controllers;

use yii\web\Controller;

/**
 * Class SiteController
 *
 * @package app\controllers
 */
class SiteController extends Controller
{
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'manage-settings' => [
                'class' => \yii2mod\settings\actions\SettingsAction::class,
                // also you can use events as follows:
                'on beforeSave' => function ($event) {
                    // your custom code
                },
                'on afterSave' => function ($event) {
                    // your custom code
                },
                'modelClass' => \app\models\forms\ConfigurationForm::class,
            ],
        ];
    }
}

Now you can access to the settings page by the following URL: http://localhost/path/to/index.php?r=site/manage-settings/, (*20)

Internationalization

All text and messages introduced in this extension are translatable under category 'yii2mod.settings'. You may use translations provided within this extension, using following application configuration:, (*21)

return [
    'components' => [
        'i18n' => [
            'translations' => [
                'yii2mod.settings' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@yii2mod/settings/messages',
                ],
                // ...
            ],
        ],
        // ...
    ],
    // ...
];

The Versions

03/03 2018

dev-master

9999999-dev

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy
by Igor Chepurnoi

settings config yii2 storage

24/12 2017

2.4

2.4.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoi

settings config yii2 storage

11/09 2017

2.3

2.3.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoi

settings config yii2 storage

13/04 2017

2.2.1

2.2.1.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

settings config yii2 storage

23/03 2017

2.2

2.2.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

settings config yii2 storage

18/02 2017

2.1

2.1.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

settings config yii2 storage

16/02 2017

2.0

2.0.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

settings config yii2 storage

12/12 2016

1.10.3

1.10.3.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

settings config yii2 storage

22/11 2016

1.10.2

1.10.2.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

settings config yii2 storage

11/11 2016

1.10.1

1.10.1.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

10/11 2016

1.10

1.10.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

10/11 2016

1.9

1.9.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

09/11 2016

1.8.1

1.8.1.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

09/11 2016

1.8

1.8.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

01/11 2016

1.7

1.7.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

03/08 2016

1.6

1.6.0.0

Yii2 Settings Module

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

25/07 2016

1.5

1.5.0.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

settings config yii2 storage

20/07 2016

1.4

1.4.0.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

14/07 2016

1.3

1.3.0.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

14/07 2016

1.2

1.2.0.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

05/07 2016

1.1

1.1.0.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

06/01 2016

1.0.2

1.0.2.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

08/10 2015

1.0.1

1.0.1.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

17/06 2015

1.0

1.0.0.0

Simple Yii2 settings extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2