Home > PHP Framework > YII > Is yii framework gii used a lot?

Is yii framework gii used a lot?

(*-*)浩
Release: 2019-11-05 10:34:08
Original
2411 people have browsed it

In my opinion, Gii of the Yii framework is a quick creator. Of course, it is of little significance for learning, but for those who already understand its principles and use it to develop, it is a good tool for rapid development. So as a main development tool for Gii, it is still used a lot.

Is yii framework gii used a lot?

##Using Gii (Recommended learning: yii tutorial)

Gii is Implemented as a module, it must be used in an existing Yii application. To use Gii, we first change the application's configuration as follows:

return array(
    ......    'modules'=>array(
        'gii'=>array(
            'class'=>'system.gii.GiiModule',            'password'=>'在这里填写密码',            // 'ipFilters'=>array(...IP 列表...),
            // 'newFileMode'=>0666,
            // 'newDirMode'=>0777,
        ),    ),);
Copy after login

Above, we declared a module named gii and its class is GiiModule. We have also set a password for this module. When we access Gii, there will be an input box asking to fill in the password.

For security reasons, only local access to Gii is allowed by default. To allow other trusted machines to access it, we need to configure the GiiModule::ipFilters property as shown above.

Because Gii generates and saves new files into the application, we need to ensure that the web server process has permission to do so. The GiiModule::newFileMode and GiiModule::newDirMode properties above control how new files and directories are generated.

Gii can now be accessed through the URL http://hostname/path/to/index.php?r=gii. Here we assume that http://hostname/path/to/index.php is the URL to access the Yii application.

If the Yii application uses URLs in the path format (see URL management), we can access Gii through the URL http://hostname/path/to/index.php/gii. We may need to add the following URL rules in front of the existing URL rules:

'components'=>array(
    ......
    'urlManager'=>array(
        'urlFormat'=>'path',
        'rules'=>array(
            'gii'=>'gii',
            &#39;gii/<controller:\w+>&#39;=>&#39;gii/<controller>&#39;,
            &#39;gii/<controller:\w+>/<action:\w+>&#39;=>&#39;gii/<controller>/<action>&#39;,
            ...已有的规则...
        ),
    ),
)
Copy after login

Gii has some default code generators. Each code generator is responsible for generating a specific type of code. For example, the controller generator generates a controller class and some action view scripts; the model generator generates an ActiveRecord class for the specified data table.

The basic process of using a generator is as follows:

Enter the generator page;

Fill in the input box for the specified code generation parameters. For example, to use Module Generator to create a new module, you need to specify the module ID;

Click the Preview button to preview the code that will be generated. You will see a table listing the files that will be generated. You can click on any of the files to preview the code;

Click the Generate button to generate these code files;

View the code generation log.

The above is the detailed content of Is yii framework gii used a lot?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
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