2

I followed the Yii-Bootstrap installation instructions on http://www.cniska.net/yii-bootstrap/setup.html but the path alias set in config/main.php doesn't work for me:

<?php
// path alias for bootstrap
Yii::setPathOfAlias('bootstrap',Yii::getPathOfAlias(dirname(__FILE__).'/../extensions/bootstrap'));
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
...

protected/extensions/bootstrap/... is my bootstrap directory.

If I want to use it in my layouts/main.php

Yii::app()->bootstrap->register();

it says "Alias "bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing directory or file. "

I tried lots of stuff but can't get it to work. Any ideas?

madth3
  • 7,275
  • 12
  • 50
  • 74
Objective
  • 848
  • 1
  • 12
  • 27
  • Try `file_exists(Yii::getPathOfAlias('bootstrap'))` to check if it point to proper directory. You can also define bootstrap component as `'class' => 'ext.bootstrap.components.Bootstrap'` –  Feb 12 '13 at 11:52
  • @PeterM thanks. I changed 'class'=>'bootstrap.components.Bootstrap', to ''class'=>'ext.bootstrap.components.Bootstrap',' and 'Yii::app()->bootstrap->register();' works now in my layout main.php. However if I use a widget like 'widget('bootstrap.widgets.TbButtonGroup', array(...' it sill says _Alias "bootstrap.widgets.TbButtonGroup" is invalid. Make sure it points to an existing directory or file._ – Objective Feb 12 '13 at 12:10
  • Have you tried `file_exists` snippet above to check directory? Also, it is more convenient to add `'ext.bootstrap.widgets.*',` to config `import` section, then you can use `$this->widget('TbButtonGroup' ...` - without typing 'bootstrap.widgets' prefix all the time. –  Feb 12 '13 at 12:15
  • @PeterM `$bool = file_exists(Yii::getPathOfAlias('bootstrap')); var_dump($bool);`outputs me unfortunately _bool(false)_ – Objective Feb 12 '13 at 13:04
  • So you have something wrong with directories. Remeber that `getPathOfAlias` and `setPathOfAlias` does **not** check if it exists. –  Feb 12 '13 at 13:08
  • @PeterM I changed it back to `Yii::setPathOfAlias('bootstrap',dirname(__FILE__).'/../extensions/bootstrap');`and suddenly it worked. Thanks for your help! – Objective Feb 12 '13 at 13:15

3 Answers3

1

Have you tried to load bootstrap automatically on you config file? Add 'bootstrap' to you preload array. Here is mine:

'preload'=>array('log', 'bootstrap'),
ventayol
  • 635
  • 4
  • 16
0

I ran into this on my production server even though it worked fine locally.

The solution was to grant apache ownership to the yii installation:

sudo chown www-data:www-data -R /var/www/yourapp

previously ownership was root and apache couldn't see the files

NewsCloud
  • 1
  • 2
0

In my case i just renamed the protected/extensions/bootstrap/components/Bootstrap.php to protected/extensions/bootstrap/components/bootstrap.php

And everything works fine.

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
Adil
  • 1