Home  >  Article  >  PHP Framework  >  Is gii based on the yii framework?

Is gii based on the yii framework?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-12-09 11:49:202362browse

Is gii based on the yii framework?

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

Gii is implemented as a module, which must be used in an existing Yii application. To use Gii, we first change the configuration of the application as follows:

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

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 via 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;,
            ...已有的规则...
        ),
    ),
)

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.

PHP Chinese website has a large number of free Yii introductory tutorials, everyone is welcome to learn!

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

Statement:
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