Ilyas karim
Ilyas karim

Reputation: 4812

How to activate Gii Code Generator in Yii 2.0.6?

I have updated my yii version using composer which is 2.0.6. When i try to locate Gii, Yii through 404 Not Found Error.

Screen Shot:

enter image description here

Composer.json File:

{
"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"
    }
}
}

Frontend/config/main-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',
        ],
    ],
];

Can anyone tell me how to activate Gii in yii2 2.0.6? Thanks in advance!

Upvotes: 2

Views: 1193

Answers (2)

Ilyas karim
Ilyas karim

Reputation: 4812

Answering my own question:

  1. First I need to change environment mode from web index.php

    `defined('YII_ENV') or define('YII_ENV', 'dev');`
    
  2. Then update main-local.php file:

    $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;
    

It is working now

Upvotes: 0

Jalali
Jalali

Reputation: 596

Change your code in /frontend/config/main-local.php to:

$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;

Upvotes: 2

Related Questions