2015-04-12 21 views
0

我剛剛安裝了yii框架,然後嘗試在其上安裝yiistrap。我也跟着上的導向: http://www.getyiistrap.com/site/startedhttp://www.yiiframework.com/forum/index.php/topic/60019-how-to-install-yiistrap-using-composer/如何安裝Yiistrap?我得到了CException屬性「CUrlManager.bootstrap」未定義

,但它涉及到了同樣的錯誤: 了CException 屬性「CUrlManager.bootstrap」沒有定義。

我使用yii-bootstrap-0.9.12.r211建議在一個成員帖子:Twitter Bootstrap in Yii,但它仍然沒有工作。

我做了3次修改:

裏面的一些推廣/引導/組件/ 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'=>'[email protected]', 
    ), 
); 

內部的意見/佈局/主。 php,在中間<head> ... </head>

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

請幫我節省我的時間。謝謝。

回答

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

謝謝@hamed,第一個障礙已經消失,但它涉及到第二個。我有新的CException:

別名「bootstrap.components.TbApi」無效。確保它指向一個現有的PHP文件並且該文件是可讀的。
作爲上stackoverflow.com/questions/21641401/...建議,我添加

'進口'=>數組(... 'bootstrap.helpers。*', 'bootstrap.widgets。*', 'bootstrap.behaviors。*',),

進入config/main.php,但它沒有工作。任何想法? Tx之前 - – puma

+0

謝謝@hamed,第一道屏障已經消失,但它涉及到第二道。我得到了新的CException:
'別名「bootstrap.components.TbApi」無效。確保它指向一個現有的PHP文件並且該文件是可讀的。 ' 我該如何解決這個問題? – puma