Yii 2.0: yii2-adsense

Widget for displaying Google AdSense banners
1 follower

Yii2 widget for displaying Google AdSense banners. This widget provides a convenient method for displaying Adsense banners in Yii2 templates.

This widget also makes it easy to disable Adsense, which can be useful for development. When disabled, this widget shows a dummy banner with the actual banner size and an indication whether this is a valid banner size for AdSense.


  • Yii2
  • Google AdSense account


Install with composer:

composer require geertw/yii2-adsense


Configure Yii params like follows:

return [
    'adsense' => [
        'client'  => 'ca-pub-1234567890123456',
        'slot'    => '1234567890',
        'enabled' => true,

Use it in your views like this:

<div style="width: 728px; height: 90px">
    <?= \geertw\Yii2\Adsense\AdsenseWidget::widget(); ?>

See the project page for more documentation.


Be the first person to leave a comment

Please to leave your comment.

Create extension