2016-06-11 56 views
2

我已经使用2.0.6作曲家更新了我的yii版本。当我尝试找到Gii时,Yii通过404找不到错误。如何在Yii 2.0.6中激活Gii代码生成器?

屏幕截图:

enter image description here

Composer.json文件:

{ 
"name": "yiisoft/yii2-app-advanced", 
"description": "Yii 2 Advanced Project Template", 
"keywords": ["yii2", "framework", "advanced", "project template"], 
"homepage": "http://www.yiiframework.com/", 
"type": "project", 
"license": "BSD-3-Clause", 
"support": { 
    "issues": "https://github.com/yiisoft/yii2/issues?state=open", 
    "forum": "http://www.yiiframework.com/forum/", 
    "wiki": "http://www.yiiframework.com/wiki/", 
    "irc": "irc://irc.freenode.net/yii", 
    "source": "https://github.com/yiisoft/yii2" 
}, 
"minimum-stability": "stable", 
"require": { 
    "php": ">=5.4.0", 
    "yiisoft/yii2": ">=2.0.6", 
    "yiisoft/yii2-bootstrap": "*", 
    "yiisoft/yii2-swiftmailer": "*" 
}, 
"require-dev": { 
    "yiisoft/yii2-codeception": "*", 
    "yiisoft/yii2-debug": "*", 
    "yiisoft/yii2-gii": "*", 
    "yiisoft/yii2-faker": "*" 
}, 
"config": { 
    "process-timeout": 1800 
}, 
"extra": { 
    "asset-installer-paths": { 
     "npm-asset-library": "vendor/npm", 
     "bower-asset-library": "vendor/bower" 
    } 
} 
} 

前端/配置/主local.php:

<?php 
return [ 
    'components' => [ 
     'request' => [ 
      // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 
      'cookieValidationKey' => '69PNggqfArD-9mR7H9lM3M0SaEBJD9Dr', 
     ], 
    ], 
]; 

谁能告诉我怎么样在yii2 2.0.6中激活Gii? 在此先感谢!

+1

http://stackoverflow.com/questions/23102922/getting-gii-to-work-on-yii-2-0 – yafater

+0

你应该改变/前端/config/main-local.php请查看链接 – yafater

+0

show'/ frontend/config/main-local.php'。 –

回答

0

回答我的问题:

  1. 首先我需要从网页的index.php改变环境模式

    `defined('YII_ENV') or define('YII_ENV', 'dev');` 
    
  2. 然后更新main-local.php文件:

    $config = [ 
        'components' => [ 
         'request' => [ 
          // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 
          'cookieValidationKey' => '69PNggqfArD-9mR7H9lM3M0SaEBJD9Dr', 
         ], 
        ], 
    ]; 
    
    if (!YII_ENV_TEST) { 
        // configuration adjustments for 'dev' environment 
        $config['bootstrap'][] = 'debug'; 
        $config['modules']['debug'] = [ 
         'class' => 'yii\debug\Module', 
        ]; 
        $config['bootstrap'][] = 'gii'; 
        $config['modules']['gii'] = [ 
         'class' => 'yii\gii\Module', 
        ]; 
    } 
    
    return $config; 
    

它现在正在

2

/frontend/config/main-local.php更改您的代码:

$config = [ 
    'components' => [ 
     'request' => [ 
      // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 
      'cookieValidationKey' => '69PNggqfArD-9mR7H9lM3M0SaEBJD9Dr', 
     ], 
    ], 
]; 

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

return $config;