PHP code example of mix8872 / yii2-config

1. Go to this page and download the library: Download mix8872/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/ */

    

mix8872 / yii2-config example snippets


'components' => [
    'config' => [
        'class' => 'mix8872\config\components\Config'
    ],

// other components
]

'controllerMap' => [
    'elfinder' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['admin'], //глобальный доступ к фаил менеджеру @ - для авторизорованных , ? - для гостей , чтоб открыть всем ['@', '?']
        'disabledCommands' => ['netmount'], //отключение ненужных команд https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'uploads',
                'name' => 'Uploads',
                'options' => [
                    'uploadOverwrite' => false,
                    'uploadAllow' => ['*'],
                    // 'uploadDeny' => ['pdf'],
                    'uploadOrder' => ['allow', 'deny'],
                    'uploadMaxSize' => '50M',
                    'disabled' => ['mkfile'],
                ],
            ]
        ]
    ],
    
    // other controllers
],
],
'modules' => [
    'config' => [
        'class' => 'mix8872\config\Module',
        'adminRole' => 'admin', // optional, defines all rights on options editing for role
        'as access' => [
            'class' => 'yii\filters\AccessControl',
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['admin']
                ],
            ]
        ]
    ],
    'gridview' =>  [
        'class' => '\kartik\grid\Module'
        // enter optional module parameters below - only if you need to
        // use your own export download action or custom translation
        // message source
        // 'downloadAction' => 'gridview/export/download',
        // 'i18n' => []
    ],
    
    // other modules
]

'modules' => [
    'config' => [
        'class' => 'mix8872\config\Module',
        'on ' . \mix8872\config\Module::EVENT_AFTER_CREATE => function ($e) {
            $model = $e->model;
            // do something
        },
        'on ' . \mix8872\config\Module::EVENT_AFTER_UPDATE => function ($e) {
            $model = $e->model;
            // do something
        },
        'on ' . \mix8872\config\Module::EVENT_AFTER_DELETE => function ($e) {
            $model = $e->model;
            // do something
        },
        'on ' . \mix8872\config\Module::EVENT_BEFORE_SAVE => function ($e) {
            $model = $e->model;
            // do something
        },
    ]
]