PHP code example of wdmg / yii2-options

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

    

wdmg / yii2-options example snippets


        
        // Get app options (default)
        $options = Yii::$app->params;
        $email = $options['adminEmail'];
        
        // Get app options (from DB)
        $options = Yii::$app->options;
        $email = $options->get('adminEmail');
        $tokenExpire = $options->get('user.passwordResetTokenExpire');
        // or
        $email = $options->adminEmail;
        $tokenExpire = $options->user->passwordResetTokenExpire;
        
        // Set app options
        $options = Yii::$app->options;
        $options->set('adminEmail', "[email protected]");
        $options->set('user.passwordResetTokenExpire', 3600);
        // or
        $options->adminEmail = "[email protected]";
        //$options->user->passwordResetTokenExpire = 3600; //@TODO Emplement later
        
    

        echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
            'label' => 'Modules',
            'items' => [
                Yii::$app->getModule('options')->dashboardNavItems(),
                ...
            ]
        ]);