1. Go to this page and download the library: Download skinka/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/ */
skinka / yii2-config example snippets
public function up()
{
Config::setNew('adminEmail', 'Administrator email', '[email protected]',
Config::TYPE_STRING, Config::INPUT_INPUT, [['email']], [], '', 0);
Config::setNew('dateTimeFormat', 'Datetime format for site', 'php:d.m.Y H:i:s',
Config::TYPE_STRING, Config::INPUT_INPUT, [['string']], [],
'Date in PHP format. All formats can be seen here: http://php.net/manual/en/function.date.php', 1);
Config::setNew('autoConfirmRegistration', 'Automatic registration', true,
Config::TYPE_BOOLEAN, Config::INPUT_DROPDOWN, [['integer']], [0 => 'Off', 1 => 'On'],
'If enabled, the user at the email will not receive a notification of the activation', 2);
//Others
}
public function down()
{
Config::delete('adminEmail');
Config::delete('dateTimeFormat');
Config::delete('autoConfirmRegistration');
//Others
}
use skinka\yii2\extension\config\Config;
/**
* Class Cfg
*
* @method static string adminEmail
* @method static string dateTimeFormat
* @method static integer autoConfirmRegistration
*/
class Cfg extends Config
{
}
if (Cfg::autoConfirmRegistration()) {
echo Cfg::adminEmail();
}
public function actions()
{
return [
'config' => [
'class' => 'skinka\yii2\extension\config\actions\ConfigAction',
]
];
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.