About how to customize the template of yii2-gii-White Wolf stack author: White Wolf Source: Ghost.
Gii in yii2 provides great convenience for our actual use.
However, in actual development, I believe that the template generated by gii will not change for many developers. why? Because they are all generated proactively using templates from other people's homes, they naturally do not meet the needs of thousands of homes, and their own needs are well customized. after all, the official website only provides a template case as much as possible.
For details about gii and how to use it, refer to the official documentation. if you do not know anything about gii, please share your comments below.
Yii2 only provides one template, but also provides us with a custom opportunity. Next, let's take a look at how to seize this opportunity to do something.
The template file used by the gii generator is located in the vendor \ yiisoft \ yii2-gii \ generators \ crud \ default directory. to customize the template, copy the default directory, paste it to any Directory. here we paste it under the giitemplate \ curd under the root directory, and then configure it as follows:
$ Config ['modules'] ['giii '] = ['class' => 'yii \ gii \ module', 'allowedips' => ['123. 0.0.1 ',': 1'], 'generator' => ['crud '=> [// Generator name 'class' => 'yii \ gii \ generators \ crud \ generator ', 'templates' => [// set our own template // template name => template path 'mycrud '=>' @ app/giitemplate/crud/default',] ,];
Then we open gii-curd, and in the last code template in curd generator, we can see the custom template. then, we can modify our gii template file as needed.