Yii2 - Gii generators - how to custom crud templates


1. Create your template folders in your application
yii2 - custom gii crud templates - folder structure








- The name of my template is "ndt"











Yii2 - using kartik Select2 as filter input of GridView



'filter' => Select2::widget([
    'name' => 'CampaignSearch[partner_id]',
    'model' => $searchModel,
    'value' => $searchModel->partner_id,
    'data' => ArrayHelper::map(
        Partner::getAll(), 'id', 'name'
    ),
    'size' => Select2::MEDIUM,
    'options' => [
        'placeholder' => '-- Tất cả --',
        'style' => 'width: 300px;'
    ],
    'pluginOptions' => [
        'allowClear' => true
    ],
    'addon' => [
        'prepend' => [
            'content' => '<i class="glyphicon glyphicon-folder-open"></i>'
        ]
    ],
]),

Yii2 session timeout settings


Edit @yourApp/config/main.php


'components' => [
    'user' => [
        'identityClass' => 'backend\models\User',
        'enableAutoLogin' => true,
        'identityCookie' => [
            'name' => '_cmsIdentity',
            'httpOnly' => true,
            'expire' => 1800,
        ],
        'authTimeout'=> 1800, // seconds
    ],
....
],

show table information

DESCRIBE table_name;
show Field from  table_name;
SHOW INDEX FROM table_name;

keepalived iptables config (vrrp protocol)

Don't forget to configure iptables to allow vrrp protocol between servers.

Example: 
# Allow keepalived
-I INPUT -i eth1 -d 224.0.0.0/8 -p vrrp -j ACCEPT
-I OUTPUT -o eth1 -d 224.0.0.0/8 -p vrrp -j ACCEPT
-I INPUT -i eth2 -d 224.0.0.0/8 -p vrrp -j ACCEPT
-I OUTPUT -o eth2 -d 224.0.0.0/8 -p vrrp -j ACCEPT

xampp: install & enable php_memcache on Window

1. Download the library that map with your PHP version.  (Ex: 5.6.x)

Download here: http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/
- XAMPP run in 32 bit. So, I choose this file: php_memcache-3.0.8-5.6-ts-vc11-x86.zip

2. Unzip and copy 2 files: php_memcache.dll & php_memcache.pdb into "ext" folder of php.
Ex: my folder is "F:\xampp\php\ext"

3. Restart apache on XAMPP

4. Test :
    php -i | findstr "memcache"

Note: 
- If you see this warning message: "PHP Warning:  PHP Startup: memcache: Unable to initialize module".
Please check your PHP version, then try to download another "php_memcache" package.

AH01630: client denied by server configuration on mac os x

1. Configure vhost

sudo vi /Applications/XAMPP/etc/extra/httpd-vhosts.conf

Listen 8000
<VirtualHost localhost:8000>
        #ServerName test.com
        DocumentRoot "/Volumes/data/projects/magento/project1/"

        <Directory "/Volumes/data/projects/magento/project1/">
                Options Indexes FollowSymLinks IncludesNoExec
                AllowOverride All
                <LimitExcept GET POST HEAD >
                        Deny from all
                </LimitExcept>
                Require all granted
        </Directory>
</VirtualHost>

2. Configure httpd.conf 
- Load vhost configuration: find & uncomment line below: 
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
- Find & configure User and Group param as below
User yourUser
Group admin