PHP code example of skeeks / yii2-config

1. Go to this page and download the library: Download skeeks/yii2-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

skeeks / yii2-config example snippets




namespace skeeks\cms\widgets;

use skeeks\yii2\config\ConfigBehavior;
use skeeks\yii2\config\ConfigTrait;
use yii\base\Widget;
use yii\helpers\ArrayHelper;

/**
 * Class GridView
 * @package skeeks\cms
 */
class TestWidget extends Widget
{
    use ConfigTrait;

    public $test = '22';

    public $config = [];

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [

            ConfigBehavior::class => ArrayHelper::merge([
                'class' => ConfigBehavior::class,
                'configModel' => [
                    'fields' => [
                        'test'
                    ],
                    'attributeDefines' => [
                        'test',
                    ],
                    'attributeLabels' => [
                        'test' => '111',
                    ],
                    'attributeHints' => [
                        'test' => '111',
                    ],
                    'rules' => [
                        ['test', 'string']
                    ]
                ]
            ], (array) $this->config),

        ]);
    }

    public function run()
    {
        return $this->test;
    }
}