Yiistrap中的CException .Alias bootstrap.helpers.TbHtml“无效

时间:2013-12-01 16:41:46

标签: php twitter-bootstrap yii

在我的Web应用程序中,我需要实现yiistrap。但是我收到此错误并且无法纠正.Alias“bootstrap.helpers.TbHtml”无效。确保它指向现有目录或文件。 我的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.
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'My Web Application',
'aliases' => array(
        'bootstrap' => realpath(__DIR__ . '/protected/config/extensions/bootstrap'), // change this if necessary
    ),
    // 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(
            'class'=>'system.gii.GiiModule',
            'password'=>'xxxx',
            // 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,
        ),
        // uncomment the following to enable URLs in path-format

            'urlManager'=>array(
                'urlFormat'=>'path',
                 'showScriptName' => false,
                 'rules'=>array(
                       '/'=>'/view',
                            '//'=>'/',
                         '/'=>'/',
                             ),             
                                ),


        /*
        'db'=>array(
            'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
        ),
                 */
        // uncomment the following to use a MySQL database

        'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=electrical',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => 'xxxxx',
            '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',
                ),
                */
            ),
        ),
'bootstrap' => array(
            'class' => 'bootstrap.components.TbApi',   
        ),
    ),


    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params'=>array(
        // this is used in contact page
        'adminEmail'=>'webmaster@example.com',
    ),
);

任何团体都会帮助我。我无法继续。

1 个答案:

答案 0 :(得分:0)

首先在您的/config/main.php中定义此内容并制作bootstrap别名

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

TbHtml不是标准的bootstrap小部件之一,也许你需要从其他地方获取它并把它放在目录/extensions/bootstrap/helpers/TbHtml中,也许它是YiiStraps助手之一