Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom templates in gii (using Yii 2)

Tags:

php

yii2

gii

I'm trying to find a way to use custom Gii templates for Yii 2, but looking at the missing documentation in the docs, I assume it's not possible yet? Or am I missing something?

like image 239
Tubelight Avatar asked Mar 13 '14 13:03

Tubelight


1 Answers

Copy ie. the crud generator templates from gii/generators/crud/templates to your application app/templates/mycrud.

Then define the templates in your config:

$config['modules']['gii'] = [
    'class'      => 'yii\gii\Module',
    'generators' => [
        'crud'   => [
            'class'     => 'yii\gii\generators\crud\Generator',
            'templates' => ['mycrud' => '@app/templates/mycrud']
        ]
    ]
];

Until the documentation is finished you may also have a look at my Gii extension how to create a custom generator and templates.

like image 81
schmunk Avatar answered Sep 23 '22 01:09

schmunk