PHP code example of davidhirtz / yii2-config

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

    

davidhirtz / yii2-config example snippets


// config/web.php
'container' => [
    'definitions' => [
        Hirtz\Config\Modules\Admin\Models\Config::class => App\Models\Config::class,
    ],
],

// app/Models/Config.php
namespace App\Models;

class Config extends \Hirtz\Config\Modules\Admin\Models\Config
{
    public array $i18nAttributes = ['claim'];

    #[\Override]
    public function rules(): array
    {
        return $this->getI18nRules([
            [['contactEmail', 'claim'], 'trim'],
            [['contactEmail'], 'email'],
            [['claim'], 'string', 'max' => 250],
        ]);
    }

    #[\Override]
    public function attributeLabels(): array
    {
        return [
            'contactEmail' => Yii::t('app', 'Contact email'),
            'claim' => Yii::t('app', 'Claim'),
        ];
    }
}