Home >PHP Framework >YII >How to open Gii in yii framework

How to open Gii in yii framework

(*-*)浩
(*-*)浩Original
2019-11-27 16:13:542992browse

How to open Gii in yii framework

Get started Gii

Gii is a module in Yii. It can be enabled by configuring the application's modules property.

Generally speaking, there will be the following configuration code in the config/web.php file: (Recommended learning: yii framework)

$config = [ ... ];

if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

This configuration indicates that if it is currently a development environment, the application will include the gii module, and the module class is yii\gii\Module.

If you check the application's entry script web/index.php, you will see this line of code setting YII_ENV_DEV to true:

defined('YII_ENV') or define('YII_ENV', 'dev');

Given the definition of this line of code , the application is in development mode, and the Gii module will be opened according to the above configuration.

You can access Gii directly via the URL:

http://hostname/index.php?r=gii

INFO: If you access Gii from a machine other than this one, the request will be denied for security reasons.

You can configure Gii to add IP addresses that allow access:

'gii' => [
    'class' => 'yii\gii\Module',
    'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // 按需调整这里
],

How to open Gii in yii framework

The above is the detailed content of How to open Gii in 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