如何安装Yiistrap?我得到CException属性“CUrlManager.bootstrap”没有定义

时间:2015-04-12 15:28:45

标签: php css yii install cexception

我刚刚安装了yii框架,然后我尝试在其上安装yiistrap。我按照指南: http://www.getyiistrap.com/site/startedhttp://www.yiiframework.com/forum/index.php/topic/60019-how-to-install-yiistrap-using-composer/

但它出现了同样的错误: 了CException 属性" CUrlManager.bootstrap"没有定义。

我按照会员帖子Twitter Bootstrap in Yii的建议使用yii-bootstrap-0.9.12.r211,但它仍然没有用。

我做了3次修改:

内部扩展/ bootstrap / components / Bootstrap.php

public function init() {
    $this->registerAllCss();
    $this->registerJs();
    parent::init();
}

在config / main.php内部

<?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.

Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');

return array(
    ...

    'theme'=>'bootstrap',
    'modules'=>array(
        'gii'=>array(
            'generatorPaths'=>array(
                'bootstrap.gii',
            ),                      
        ),
    ),

    // preloading 'log' component
    'preload'=>array('log'),

    // autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
        'bootstrap.helpers.TbHtml',
    ),

    'modules'=>array(
        // uncomment the following to enable the Gii tool
        'gii'=>array(
            ...
          ),
    ),

    // application components
    'components'=>array(

        'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
        ),

        // uncomment the following to enable URLs in path-format
        'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),

        'bootstrap'=>array(
        'class'=>'bootstrap.components.Bootstrap',
            ),

        ),

                // database settings are configured in database.php
        'db'=>require(dirname(__FILE__).'/database.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'=>'webmaster@example.com',
    ),
);

内部views / layouts / main.php,位于<head> ... </head>

的中间
<?php Yii::app()->bootstrap->register(); ?>

请帮我节省时间。感谢。

1 个答案:

答案 0 :(得分:0)

您已在url-manager数组中定义了'bootstrap'。这是不正确的。你应该这样做:

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

'bootstrap'=>array(
    'class'=>'bootstrap.components.Bootstrap',
 ),