2

http://www.yiiframework.com/doc/blog/1.1/en/prototype.scaffoldチュートリアルに続いて、/ 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',
        ),
    ),
);

これらは、main.phpのコードの最後の数行です。ご覧のとおり、指示に従いました...

        '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',
        ),
    ),
);

しかし、index.php?r = giiにアクセスすると、次のエラーが発生します。

Error 404 Unable to resolve the request "gii".

参考までに-私は最新の安定したリリースであるバージョン1.1.12を使用しています。

アップデート

すべてを削除してやり直しましたが、現在は機能しています。途中で愚かなことをしたに違いない

4

3 に答える 3

0

ここhttp://pastebin.com/x3zWWLtmの21行目にすでに'modules'構成配列のキーがあります。手動で追加したキーを削除し、21行目でそのキーのコメントを解除します。'modules''gii'

<?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'),
                ),
                */
        ),
        // ...
    );

最新のyiiをダウンロードして、Webアプリケーションを作成しました。

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

gii次に、私が述べたようにconfigに含まれるモジュールの行のコメントを外し、完全に機能しています: http://localhost/yiiapp/index.php?r=gii

于 2012-09-19T20:22:22.537 に答える
0

さて、次のような別の uri を試しましたlocalhost/site/errorか?

404 を取得した場合、それは.htaccessの問題です。次のコードをルート ディレクトリの下の.htaccessファイルに保存してみてください。

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]
于 2014-06-09T00:30:21.200 に答える
0

私は同じ問題を抱えていて、rulesキーの値である配列の内容をconfig/main.phpで一時的にコメントしました:

'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,
),

次に、にアクセスgiiし、コントローラーとビューを生成し、最後にそれらの行のコメントを外しました。

于 2013-07-31T16:51:07.137 に答える