Home > Backend Development > PHP Tutorial > In-depth analysis of yii2-gii custom template method, brief analysis of yii2-gii_PHP tutorial

In-depth analysis of yii2-gii custom template method, brief analysis of yii2-gii_PHP tutorial

WBOY
Release: 2016-07-12 08:53:26
Original
1074 people have browsed it

In-depth analysis of yii2-gii custom template methods, brief analysis of yii2-gii

Foreword:

What is Yii

Yii is a high-performance, component-based PHP framework for rapid development of modern web applications. The name Yii (pronounced `易`) has dual meanings in Chinese of "extreme simplicity and continuous evolution", and can also be seen as the abbreviation of **Yes It Is**!

What is Yii best suited for?

Yii is a general web programming framework that can be used to develop various PHP-based web applications. Because of its component-based framework structure and well-designed caching support, Yii is particularly suitable for developing large-scale applications, such as portals, forums, content management systems (CMS), e-commerce projects, and RESTful web services.

Yii version

Yii currently has two major versions: 1.1 and 2.0. Version 1.1 is an older version of the previous generation and is currently under maintenance. Version 2.0 is a completely rewritten version, using the latest technologies and protocols, including dependency package manager (Composer), PHP Code Specification (PSR), namespaces, Traits (traits), etc. Version 2.0 represents the latest generation of the framework and will be our main development release over the next few years. This guide is primarily based on version 2.0.

Text:

Gii in yii2 provides great convenience for our actual use.

However, in actual development, I believe that the templates generated by gii have also brought stability to many developers. Why? Because they are all generated proactively using other people's templates, they naturally do not meet the needs of tens of thousands of families. It is better to customize them for your own needs. After all, the official only tries to give a template case as much as possible.

For the introduction of gii and how to use it, please refer to the official documentation. If you don’t understand anything, leave a message below and we can communicate together.

yii2 officially only provides one template, but it also provides us with the opportunity to customize it. Next, let’s see how to seize this opportunity to do something.

The template file used by the gii generator is located in the directory vendoriisoftyii2-giigeneratorscruddefault. Because we need to customize the template, we now copy the default directory and paste it into any directory. Here we paste it under the giitemplatecurd in the root directory, and then follow Configure below

$config['modules']['gii'] = [
'class' => 'yii\gii\Module', 
'allowedIPs' => ['127.0.0.1', '::1'], 
'generators' => [ 
'crud' => [ //生成器名称 
'class' => 'yii\gii\generators\crud\Generator', 
'templates' => [ //设置我们自己的模板 
//模板名 => 模板路径 
'myCrud' => '@app/giitemplate/crud/default', 
] 
] 
], 
];
Copy after login

Then we open gii-curd. In the last code template in the curd generator, we can see the customized template. Then, we can modify our own gii template file as we like.

The above is the method of yii2-gii custom template introduced by the editor. I hope it will be helpful to everyone!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1123831.htmlTechArticleIn-depth analysis of the method of yii2-gii custom template, brief analysis of yii2-gii Preface: What is Yii? A high-performance, component-based PHP framework for rapid development of modern web applications. ...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template