Twitter bootstrap 似乎不能在Yii中包含Twitter引导

Twitter bootstrap 似乎不能在Yii中包含Twitter引导,twitter-bootstrap,yii,yii-extensions,Twitter Bootstrap,Yii,Yii Extensions,我今天刚开始使用Yii,我正在努力让bootstrap正常工作 我试着按照这些说明去做,但还是不行。my/protected/config/main.php如下所示 <?php // uncomment the following to define a path alias // Yii::setPathOfAlias('local','path/to/local-folder'); // Define a path alias for the Bootstrap extension

我今天刚开始使用Yii,我正在努力让bootstrap正常工作

我试着按照这些说明去做,但还是不行。my/protected/config/main.php如下所示

<?php

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

// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'My Site',
    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory

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

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

    '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'),
            'generatorPaths' => array('bootstrap.gii'),
        ),

    ),

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

        'bootstrap' => array(
            'class' => 'bootstrap.components.Bootstrap',
        ),
        // 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>',
            ),

        ),

        /*'db'=>array(
            'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
        ),*/

        // uncomment the following to use a MySQL database

        'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=DBNAME',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ),

        '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'=>'admin@blablabla',
    ),
);
你必须把Yii::app->bootstrap->register;要使用引导的位置。通常是主布局


添加到第节中的/protected/layouts/main.php中。

不要这样注册它,而是尝试将它添加到预加载中:除了PitchInner的建议之外,还可以尝试这样做:“预加载”=>array'log',“bootstrap”,这应该可以解决您当前的问题,我不相信这个扩展已经被保留了下来——您可能会更幸运地使用yiistrap ext:@PrplHaz4谢谢,这很有效。但出于好奇,我应该把代码@PitchInnated?@user2636556放在哪里,预加载代码放在config/main.php中,可能已经有了“log”的条目,如PitchInnated的示例所示
Fatal error: Uncaught exception 'CException' with message 'Property "CWebApplication.bootstrap" is not defined.' in /Applications/XAMPP/xamppfiles/htdocs/dev2/framework/base/CComponent.php:130 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/dev2/framework/base/CModule.php(105): CComponent->__get('bootstrap') #1 /Applications/XAMPP/xamppfiles/htdocs/dev2/protected/config/main.php(10): CModule->__get('bootstrap') #2 /Applications/XAMPP/xamppfiles/htdocs/dev2/framework/base/CApplication.php(133): require('/Applications/X...') #3 /Applications/XAMPP/xamppfiles/htdocs/dev2/framework/YiiBase.php(125): CApplication->__construct('/Applications/X...') #4 /Applications/XAMPP/xamppfiles/htdocs/dev2/framework/YiiBase.php(98): YiiBase::createApplication('CWebApplication', '/Applications/X...') #5 /Applications/XAMPP/xamppfiles/htdocs/dev2/index.php(13): YiiBase::createWebApplication('/Applications/X...') #6 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/dev2/framework/base/CComponent.php on line 130