2

Following http://www.yiiframework.com/doc/blog/1.1/en/prototype.scaffold tutorial, it mentions to add some code to /blog/protected/config/main.php

return array(
    ......
    'import'=>array(
        'application.models.*',
        'application.components.*',
    ),

    'modules'=>array(
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'pick up a password here',
        ),
    ),
);

These are the last few lines of my code for main.php, as you can see, I have followed instructions...

        'errorHandler'=>array(
            // use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
        'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error, warning',
                ),
                // uncomment the following to show log messages on web pages
                /*
                array(
                    'class'=>'CWebLogRoute',
                ),
                */
            ),
        ),
    ),

    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params'=>array(
        // this is used in contact page
        'adminEmail'=>'example@example.com',
    ),
    'import'=>array(
        'application.models.*',
        'application.components.*',
    ),
    'modules'=>array(
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'pick up a password here',
        ),
    ),
);

Yet when I visit index.php?r=gii, I get the following error:

Error 404 Unable to resolve the request "gii".

FYI - I am using version 1.1.12 which is the latest stable release.

UPDATE

I deleted everything and started again, and now is working. must have done something silly en-route

Gravy
  • 12,264
  • 26
  • 124
  • 193

3 Answers3

0

You're already have 'modules' key of configuration array at the line 21 here http://pastebin.com/x3zWWLtm . Remove the key 'modules' which you've added manually and uncomment 'gii' in that one at line 21:

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
        // ...

        'modules'=>array(
                // uncomment the following to enable the Gii tool
                /*
                'gii'=>array(
                        'class'=>'system.gii.GiiModule',
                        'password'=>'Enter Your Password Here',
                        // If removed, Gii defaults to localhost only. Edit carefully to taste.
                        'ipFilters'=>array('127.0.0.1','::1'),
                ),
                */
        ),
        // ...
    );

I've just downloaded latest yii and created a web application:

f0t0n@lotus:~/public_html/localhost/yii$ php framework/yiic webapp ../yiiapp

Then uncommented the lines of gii module including in config as I've mentioned and it's working perfect: http://localhost/yiiapp/index.php?r=gii

Eugene Naydenov
  • 7,165
  • 2
  • 25
  • 43
  • I tried that already... It didn't work. That's why I commented it out again and tried adding it at the end... just in case. – Gravy Sep 19 '12 at 20:24
  • config.php should have only one array of modules else it will be overridden by the last array. Same problem occurred for me solved it by combining the two modules array into one with respective arrays. – Wasim Pathan Nov 03 '14 at 07:01
0

I had the same problem and I just commented temporarily, in config/main.php, the content of the array that is the value of the rules key:

'urlManager'=>array(
    'urlFormat'=>'path',
    'rules'=>array(/*
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>'=>'<controller>/index',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>'*/
    ),
    'showScriptName'=>false,
),

Then I accessed gii, generated my controller and view and finally uncommented those lines.

felipe.zkn
  • 2,012
  • 7
  • 31
  • 63
0

Well, did you try another uri, like: localhost/site/error?

If got 404 then it's a .htaccess issue, try to save the following code in .htaccess file under your root directory:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule ^.*$ /index.php [L]
Mohammad Anini
  • 5,073
  • 4
  • 35
  • 46