PHP code example of antonyz89 / yii2-templates

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

    

antonyz89 / yii2-templates example snippets


if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['bootstrap'] = ['gii'];
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'generators' => [
            'model' => [
                'class' => 'antonyz89\templates\model\Generator',
                'templates' => [
                    'default' => '@antonyz89/templates/model/default', // add default template
                ]
            ],
            'crud' => [
                'class' => 'antonyz89\templates\crud\Generator',
                'templates' => [
                    'admin-lte' => '@antonyz89/templates/crud/admin-lte', // add admin-lte template
                    'material-lite' => '@antonyz89/templates/crud/material-lite', // add material-lite template
                    'material-bootstrap' => '@antonyz89/templates/crud/material-bootstrap', // add material-bootstrap template
                    'default' => '@antonyz89/templates/crud/default', // add default template
                ]
            ]
        ],
    ];
}

use antonyz89\templates\assets\YiiTemplatesAsset;

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [];
    public $js = [];
    public $depends = [
        YiiTemplatesAsset::class // ADD
    ];
}

GridView::widget([
    'dataProvider' => $dataProvider,
    'pjax' => true, // here
    'columns' => [
        'id',
        'name',
        [
            'class' => 'kartik\grid\ActionColumn',
            'width' => '150px',
            'buttonOptions' => [
                'class' => 'btn btn-sm btn-default'
            ],
            'updateOptions' => [
                'class' => 'btn btn-sm btn-primary'
            ],
            'deleteOptions' => [
                'class' => 'btn btn-sm btn-danger'
            ]
        ]
    ]
]);

<div class="example-search">

     $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'options' => [
            'data-pjax' => true // HERE
        ],
    ]); 

 $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'options' => [
            'data-pjax' => true,
            'pjax-only-on-submit' => true // HERE
        ],
    ]); 

// Query
User::find()->alias('example')->where(['@alias.name' => 'Antony'])->groupBy('@alias.age');