Twitter Bootstrap in Yii

dibs_ab picture dibs_ab · Aug 8, 2012 · Viewed 9.9k times · Source

I'm pretty new to Yii as well as Twitter Bootstrap, I am trying to use the files provided by bootstrap. I have unzipped the downloaded folder in extensions directory of protected folder in Yii, and followed this http://www.cniska.net/yii-bootstrap/setup.html#setup The code in my main.php looks like:

'preload'=>array('log','bootstrap'),
'import'=>array(
...
'application.extensions.bootstrap.widgets.*',
),
'modules'=>array(
     'generatorPaths'=>array(
        'bootstrap.gii',
      ),

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

I get this error
Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file.

Q2. Is there any better way other than just copy paste the whole bootstrap css file in Yii's css?

Q3. Do I have to download anything extra to use the widgets provided by bootstrap twitter like, $this->widget('ext.cssmenu.CssMenu',array(...); where should the downloaded files be located?

Answer

DaveR picture DaveR · Aug 9, 2012

I think you might be downloading the wrong files! You don't download bootstrap from the twitter github page - instead you download the yii extension, which has all the boostrap files bundled in.

Here's a step by step guide:

  1. Download this file - http://www.yiiframework.com/extension/bootstrap/files/yii-bootstrap-0.9.12.r211.zip - I'd use this rather than the alpha v 1.0 for stability.

  2. Unzip it

  3. Rename the unzipped folder to 'bootstrap'

  4. check that you have the folder structure ernie mentions below.

  5. upload your new bootstrap folder to protected/extensions

  6. make the changes to your protected/config/main.php given here - http://www.cniska.net/yii-bootstrap/setup.html#setup - but it looks like you've already done this.

Everything should now be working.