让Gii在Yii 2.0上工作

tar*_*req 9 php crud gii yii2

我下载了高级模板,解压缩并更改了后端和前端的根文档,但我似乎无法弄清楚如何让Gii工作来执行crud操作.

在composer.JSON中有require和require-dev字段我在其中包含了gii,并且每个都分别没有运气.

我也尝试通过作曲家获取模板,并在安装时看到gii已安装,但仍无法使其工作.

这是我得到我的Yii模板的地方:https://github.com/yiisoft/yii2-app-advanced

小智 20

这是如何让Gii从远程服务器工作以获得高级设置模板.

在前端配置文件中.例如:

/frontend/config/main-local.php
Run Code Online (Sandbox Code Playgroud)

添加以下代码:

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii']=[
      'class' =>  'yii\gii\Module',
      'allowedIPs' => ['*'],
    ];
}
Run Code Online (Sandbox Code Playgroud)

有趣的部分是array经过修改的Gii .


Ksh*_*tiz 10

第1步:将以下行添加到composer.json的required-dev

"yiisoft/yii2-gii": "*"
Run Code Online (Sandbox Code Playgroud)

第2步:更新您的作曲家.第3步:将以下行添加到您的前端/ config/main.php文件中.不要这些..........

  'modules' => [
    ............
    'gii' => [
      'class' => 'yii\gii\Module', //adding gii module
      'allowedIPs' => ['127.0.0.1', '::1']  //allowing ip's 
    ],
    ...........
  ]
Run Code Online (Sandbox Code Playgroud)

第4步:如果您启用了干净的网址,请转到

project_name/frontend/web/gii
Run Code Online (Sandbox Code Playgroud)

如果不是那么去

project_name/frontend/web/index.php?r=gii
Run Code Online (Sandbox Code Playgroud)

你可以点击链接yii2_gii


Mis*_*cha 5

文档中所述您必须在/frontend/config/main-local.php中调整允许的IP :

    if (!YII_ENV_TEST) {
      ...
      $config['bootstrap'][] = 'gii';
      $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '192.168.*.*']
      ];
    }
Run Code Online (Sandbox Code Playgroud)

如果您已经为漂亮的网址修改了/frontend/config/main.php,则:

    return [
    ...
    'components' => [
      ...
      'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false
      ],
      ...
    ];
Run Code Online (Sandbox Code Playgroud)

您可以使用URL呼叫gii

    yourVM.local/gii
Run Code Online (Sandbox Code Playgroud)

(在您的主机文件中,将yourVM.local指向您的前端模块。)