dsjgk330337 2014-05-21 04:32
浏览 39
已采纳

Yii模块无法在我的网站上运行

I have a website powered by yii framework.

Yii Version: 1.1.14

Php version: above 5.4

I tried to install a forum module from the following location

http://www.yiiframework.com/extension/bbii

I added the modules in the main.php as specified in the readme file. But the /forum is not working and I tried some other modules and none of them are working on my installation. I am stuck at the moment and I tried google but it is like a unique error and I don't know how to debug it. Please help. Thanks

return array(
        'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
        'name'=>'testapp',
        'preload'=>array('log','bootstrap'),
        'import'=>array(
            'application.models.*',
            'application.components.*',
            'application.vendor.*',
            'application.controllers.NavSort*',
            ),
        'modules'=>array(
            'gii'=>array(
                'class'=>'system.gii.GiiModule',
                'password'=>'123',
                // If removed, Gii defaults to localhost only. Edit carefully to taste.
                'ipFilters'=>array('127.0.0.1','::1'),
                'generatorPaths' => array(
                        'bootstrap.gii'
                    ),
                ),
            'forum'=>array(
                'class'=>'application.modules.bbii.BbiiModule',
                'adminId'=>1,
                'userClass'=>'User',
                'userIdColumn'=>'id',
                'userNameColumn'=>'username',
                ),
            ),
        'homeUrl'=>array('site/login'),
        // application components
        'components'=>array(
            'bootstrap' => array(
                'class' => 'ext.yiibooster.components.Bootstrap',
                ),
            'user'=>array(
                // enable cookie-based authentication
                'allowAutoLogin'=>true,
                ),          
            'session'=>array(
                'autoStart'=>true,
                'sessionName'=>'session',
                'cookieMode' => 'only',
                'timeout'=>86400,
                ),
            'urlManager'=>array(
                'urlFormat'=>'path',
                'showScriptName'=>false,
                //'urlSuffix'=>'.html',
                'urlSuffix'=>'',
                'class' => 'UrlManager',
                'rules'=>array(
                    '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                    '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                    '<controller:[\w\-]+>/<action:[\w\-]+>' => '<controller>/<action>',
                     // defaults to a site page if not above
                    '<view:[a-zA-Z0-9-]+>/'=>'site/login',
                    ),
                ),
            'db'=>array(
                'connectionString' => 'pgsql:host=localhost;port=5432;dbname=testdb',
                'emulatePrepare' => false,
                'username' => 'postgres',
                'password' => 'root', 
                //'tablePrefix'=>'',
                'charset' => 'utf8',
                ),
            'errorHandler'=>array(
                'errorAction'=>'site/error',
                ),
            'log'=>array(
                'class'=>'CLogRouter',
                'routes'=>array(
                    array(
                        'class'=>'CFileLogRoute',
                        'levels'=>'error, warning',
                        ),
                    ),
                ),
            ),
        'params'=>array(
            // this is used in contact page
            'adminEmail'=>'info@site.com',
            ),
        );
  • 写回答

1条回答 默认 最新

  • dongruoqiong9017 2014-05-21 06:51
    关注

    You are missing URL rules that would direct framework into opening a module.

    You can use both universal rules

    '<module:\w+>/<controller:\w+>/<action:[\w-]+>' => '<module>/<controller>/<action>',
    '<module:\w+>/<controller:\w+>'                 => '<module>/<controller>',
    '<module:\w+>'                                  => '<module>',
    

    Or you can create specific rules

    'forum/<controller:\w+>/<action:[\w-]+>'        => 'forum/<controller>/<action>',
    'forum/<controller:\w+>'                        => 'forum/<controller>',
    'forum'                                         => 'forum',
    

    The difference is only when universal rules conflict with other rules, then you should use more specific ones.

    For example, to make Gii in my application work correctly with my multi-language system, I use following rule

    'gii/<controller:\w+>/<action:[\w-]+>'          => 'gii/<controller>/<action>',
    

    And remember, it matters, where you position your URL rules in that array. First one that will match, will trigger opening that specific action. Read more about URL Management.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失