Preface:
What is YII?
Yii is a high-performance, component-based PHP framework for rapid development of modern WEB applications. The name Yii (read as ' Easy ') has the dual meaning of "extreme simplicity and constant evolution" in Chinese, also can be regarded as **yes It is**! The abbreviation.
What is Yii best suited to do?
Yii is a common web programming framework that can be used to develop a variety of PHP-based Web applications. Because of its component-based framework and well-designed cache support, YII is ideal for developing large-scale applications such as portals, forums, Content management systems (CMS), e-commerce projects, and RESTful WEB services.
Yii version
There are currently two major versions of YII: 1.1 and 2.0. Version 1.1 is the old version, and is now in the maintenance state. Version 2.0 is a fully rewritten version that incorporates the latest technologies and protocols, including the dependency Package Manager (Composer), PHP Code specification (PSR), namespaces, Traits (traits), and more. Version 2.0 represents the latest generation of frameworks and is our main development in the coming years. This guide is primarily based on version 2.0.
Body:
The GII in Yii2 provides a great convenience for our practical use.
However, in actual development, we believe that the template generated by the GII has also brought the same to many developers, why? Because all are the template initiative generated by others, nature does not meet the needs of the thousands, the needs of their own custom is good, after all, the official is just as far as possible to give a template case.
For an introduction to the GII and how to use it, refer to the official documentation, and if there is anything you don't understand, we'll share the message below.
YII2 official only provided a template, but also gave us the opportunity to customize, next we see how to seize the opportunity to do something.
The template file used by the GII generator is located in directory Vendor\yiisoft\yii2-gii\generators\crud\default, because to customize the template, we now copy the default directory, paste it into any directory, Here we paste the Giitemplate\curd under the root directory, and then configure it as follows
$config [' Modules '] [' gii '] = [' class ' = ' Yii\gii\module ', ' allowedips ' = ' = ' 127.0.0.1 ', ':: 1 '], ' generators ' = [' 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, in the last code template in curd generator, we can see the custom template, then we can modify our own gii template file as we like.
The above is a small series to introduce you to the Yii2-gii custom template method, we hope to help!