【问题标题】:Invalid Bootstrap path and CDN URL in Yiistrap for Yii FrameworkYii Framework 的 Yiistrap 中的引导路径和 CDN URL 无效
【发布时间】:2015-07-24 09:55:56
【问题描述】:

我有一个基于 Yii 框架的项目。我按照本指南为我的 yii 项目实施了 boostrap,但出现错误:

Invalid Bootstrap path and CDN URL not set. Set vendor.twbs.bootstrap.dist alias or cdnUrl parameter in the configuration file. 

这是网址http://www.getyiistrap.com/site/started

我关注了一切。我没有使用作曲家。我刚刚下载了 zip 文件。

这是我的配置文件供参考:

<?php

// 取消注释以下定义路径别名 // Yii::setPathOfAlias('local','path/to/local-folder');

// 这是主要的 Web 应用程序配置。任何可写的 // CWebApplication 属性可以在这里配置。 返回数组( 'basePath'=>dirname(FILE).DIRECTORY_SEPARATOR.'..', 'name'=>'我的网络应用程序',

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

 // path aliases
'aliases' => array(
    'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'), // change this if necessary
),

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

),

'modules'=>array(
    // uncomment the following to enable the Gii tool

    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'password',
        // 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.TbApi',   
        ),

    // 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>',
        ),
    ),


    // 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',
),
);

我遵循了放置引导文件的位置。我一直在互联网上搜索,但找不到答案。谢谢

【问题讨论】:

    标签: php css twitter-bootstrap yii


    【解决方案1】:
    1. config/main.php的开头添加:

      Yii::setPathOfAlias('bootstrap', dirname(__FILE__) . '/../extensions/bootstrap');
      
    2. 然后在组件中:

      // application components
      'components' => array(
      ...
          'bootstrap' => array(
              'class' => 'bootstrap.components.Bootstrap'
      ),
      
    3. 并删除您的代码:

       // path aliases
      'aliases' => array(
      'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'),
      ),
      
    4. 检查引导程序是否在extensions/bootstrap

    这样它应该可以工作。

    【讨论】:

      【解决方案2】:

      我假设你使用的是 YiiStrap 2.x.x

      你可以设置

      // path aliases
      'aliases' => array(
          'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'),
          'vendor.twbs.bootstrap.dist' => realpath(__DIR__ . '/../extensions/bootstrap'),
      ),
      

      并且错误消失了。 但我认为 YiiStrap 2.x.x 仍然不稳定且有问题,所以我不得不回滚到 1.x.x 并等待稳定发布。

      【讨论】:

        猜你喜欢
        • 2015-10-02
        • 1970-01-01
        • 2015-05-11
        • 2016-06-06
        • 1970-01-01
        • 2013-12-23
        • 1970-01-01
        • 1970-01-01
        • 2018-03-05
        相关资源
        最近更新 更多