About how to customize a template in yii2-gii

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.