Bootsrap Glyph Icons?

Ok, so I am toying with Yii 2.0 Beta and want to include a glyph icon from Bootstrap on my page. Instead of generating the glyph icon, the source code is shown on my pages like so:

<i class="icon-search"></i>

What am I missing?

Seems an older version of bootstrap. Can you check if Bootstrap 3.x is loaded (OR are you using any other extensions that use old Bootstrap version). Your icon markup should be generated something like the following for BS3:

<i class="glyphicon glyphicon-search"></i>

Depends on where you’re specifying it.

Thank you for the quick reply. This is a clean install of Yii 2.0 Beta (Advanced Template) using all default settings. As per vendor/yiisoft/yii2-bootstrap/CHANGELOG, it is using Bootstrap 3.

Bootstrap is loaded in composer.json as follows:

"require": {

		"php": ">=5.4.0",

		"yiisoft/yii2": "*",

		"yiisoft/yii2-bootstrap": "*",

		"yiisoft/yii2-swiftmailer": "*"


I tried modifying the markup as you suggested, but it still will not render the glyphicon.

My php view file starts with the following:


     use yii\bootstrap\Nav;

     use yii\bootstrap\NavBar;

Is this correct? Is something else required?

Yes, it’s correct. Please should the place where you’re modifying it to use icons.

Okay, Thank You.

I got it working on the view file, but It will not work in the $menuItems[] array.

I would like to use a glyph icon in the label as so:

$menuItems[] = ['label' => '<i class="glyphicon glyphicon-search"></i> Search', 'url' => ['/site/search']];

I’m sorry to be a pain. I’m fairly new to Yii and am trying to learn on-the-fly.

Menu widget automatically encodes all its labels for security reasons. In order to turn it off:

echo Nav::widget([

    'options' => ['class' => 'navbar-nav navbar-right'],

    'items' => $menuItems,

    'encodeLabels' => false,


Don’t forget to encode your labels manually with Html::encode() if these are not static.

Excellent! That resolved my problem. Thanks for the help. I am so glad to see how responsive the Yii Community has been.

Thx it’s work, testing on font awesome icons.