Showing posts with label Gii. Show all posts
Showing posts with label Gii. Show all posts

Sunday, 4 August 2013

Activate Gii code generator for frontend in YiiBoilerPlate

1) First check the directory "runtime" exist or not in frontend folder if not then create it.
2) Go to folder frontend/config
3) Open file main.php
4) Add the following line in array()

'modules' => array(
                'gii' => array(
                    'class' => 'system.gii.GiiModule',
                    'password' => '<your_gii_password>',
                    'generatorPaths' => array(
                        'bootstrap.gii'
                    )
                ),
            ),

i.e.

return CMap::mergeArray(
                array(
            // @see http://www.yiiframework.com/doc/api/1.1/CApplication#basePath-detail
            'basePath' => 'frontend',
            // set parameters
            'params' => $params,
            // preload components required before running applications
            // @see http://www.yiiframework.com/doc/api/1.1/CModule#preload-detail
            'preload' => array('log'),
            // @see http://www.yiiframework.com/doc/api/1.1/CApplication#language-detail
            'language' => 'en',
            // uncomment if a theme is used
            /* 'theme' => '', */
            // setup import paths aliases
            // @see http://www.yiiframework.com/doc/api/1.1/YiiBase#import-detail
            'import' => array(
                'common.components.*',
                'common.extensions.*',
                'common.models.*',
                // uncomment if behaviors are required
                // you can also import a specific one
                /* 'common.extensions.behaviors.*', */
                // uncomment if validators on common folder are required
                /* 'common.extensions.validators.*', */
                'application.components.*',
                'application.controllers.*',
                'application.models.*'
            ),
            /* uncomment and set if required */
            // @see http://www.yiiframework.com/doc/api/1.1/CModule#setModules-detail
            /* 'modules' => array(), */
            'components' => array(
                'errorHandler' => array(
                    // @see http://www.yiiframework.com/doc/api/1.1/CErrorHandler#errorAction-detail
                    'errorAction' => 'site/error'
                ),
                'db' => array(
                    'connectionString' => $params['db.connectionString'],
                    'username' => $params['db.username'],
                    'password' => $params['db.password'],
                    'schemaCachingDuration' => YII_DEBUG ? 0 : 86400000, // 1000 days
                    'enableParamLogging' => YII_DEBUG,
                    'charset' => 'utf8'
                ),
                'urlManager' => array(
                    'urlFormat' => 'path',
                    'showScriptName' => false,
                    'urlSuffix' => '/',
                    'rules' => $params['url.rules']
                ),
            /* make sure you have your cache set correctly before uncommenting */
            /* 'cache' => $params['cache.core'], */
            /* 'contentCache' => $params['cache.content'] */
            ),
            /* uncomment and set if required */
// @see http://www.yiiframework.com/doc/api/1.1/CModule#setModules-detail
            'modules' => array(
                => array(
                    'class' => 'system.gii.GiiModule',
                    'password' => 'admin',
                    'generatorPaths' => array(
                        'bootstrap.gii'
                    )
                ),
            ),
                ), CMap::mergeArray($mainEnvConfiguration, $mainLocalConfiguration)
);

5) Check it by accessing http://your_domain/gii

Thanks

Fix Gii Error 403 You are not allowed to access this page (Yii Framework)

After configuring Yii framework or YiiBoilerPlate you might be getting following error while accessing Gii code generator:

Error 403
You are not allowed to access this page:

This can be happen in your localhost or remote host wherever you are developing your web app. To resolve this you need to add your development computer’s IP address to your main.php file as follows:

In Yii Framework

1) Go to yourwebapp/protected/config folder.
2) Open main.php file.
3) Add the following line in main.php in "gii" array as follows:

'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => 'admin',
            'ipFilters' => array('127.0.0.1', $_SERVER['REMOTE_ADDR'])
),

YiiBoilerPlate

And if you are using YiiBoilerPlate then go to yourwebapp/backend (or frontend)/config/main.php file and add the same line in Gii array.