PHPackages                             snapshotpl/zf-snap-google-adsense - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. snapshotpl/zf-snap-google-adsense

ActiveLibrary

snapshotpl/zf-snap-google-adsense
=================================

Google Adsense view helper for Zend Framework 2

1.0.1(12y ago)15.3kPHP

Since Feb 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/snapshotpl/ZfSnapGoogleAdSense)[ Packagist](https://packagist.org/packages/snapshotpl/zf-snap-google-adsense)[ Docs](https://github.com/snapshotpl/ZfSnapGoogleAdSense)[ RSS](/packages/snapshotpl-zf-snap-google-adsense/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

ZfSnapGoogleAdSense [![Build Status](https://camo.githubusercontent.com/0aa193599fd8e0fc94b4c8a943e954a083f81a6be477688c99a6b0b9dd19819a/68747470733a2f2f7472617669732d63692e6f72672f736e617073686f74706c2f5a66536e6170476f6f676c65416453656e73652e706e673f6272616e63683d312e302e30)](https://travis-ci.org/snapshotpl/ZfSnapGoogleAdSense) [![Scrutinizer Quality Score](https://camo.githubusercontent.com/63e8570665bf59c13e14ec130431248876df384558308948ad4881f9fc65b4a8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736e617073686f74706c2f5a66536e6170476f6f676c65416453656e73652f6261646765732f7175616c6974792d73636f72652e706e673f733d39663965383130393533336361646166613630646339303833396338656461653032663835383032)](https://scrutinizer-ci.com/g/snapshotpl/ZfSnapGoogleAdSense/)
============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#zfsnapgoogleadsense--)

Google AdSense view helper for Zend Framework 2

Module helps to manage yours AdSense units on page. Keep them all in one place and use renderers!

The simplest usage
------------------

[](#the-simplest-usage)

Add ad unit (one or more) and publisher ID (you can [find it here](https://www.google.com/adsense/app#accountInformation)) to your config:

```
return array(
  'zf-snap-google-adsense' => array(
    'publisher-id' => 'pub-1234567890123456',
    'ads' => array(
      'home-page' => array(
        'id' => 1234567890,
        'size' => '336x280',
      ),
    ),
  ),
);
```

And then render ad in your view by view helper. You can use googleAdsense or adsense name:

```
echo $this->adsense('home-page');
```

That's all! In default adsense use asynchronous code. You can change it by using predefined view renderers.

How to install?
---------------

[](#how-to-install)

Via [composer.json](https://getcomposer.org/)

```
{
  "require": {
    "snapshotpl/zf-snap-google-adsense": "1.*"
  }
}
```

Renderers
---------

[](#renderers)

You can use renderes (by implements `ZfSnapGoogleAdSense\View\Helper\Renderer\RendererInterface`) to render your ads. In default module provides simple view renderer with very useful views:

- **asynchronous** (default): official asynchronous script,
- **synchronous**: official synchronous script,
- **placeholdit**: fake placeholer is using [placehold.it](http://placehold.it/) service to generate image, perfect for dev or test eviroments, you can customize it, to details see `config/module.config.php` and overwrite options,
- **html**: generates html div, perfect for dev or test eviroments, you can customize it, to details see `config/module.config.php` and overwrite options,

To add own view to view render create view (in view you can use `ad` property which it's instance of `\ZfSnapGoogleAdSense\Model\AdUnit` by default) add it to view\_manager with prefix `zf-snap-google-adsense-renderer-view-*`:

```
return array(
  'view_manager' => array(
    'template_map' => array(
      'zf-snap-google-adsense-renderer-view-customview' => __DIR__ . '/my-awesome-custom-view.phtml',
    ),
  ),
);
```

To change current view renderer pass view name to `renderer` option:

```
return array(
  'zf-snap-google-adsense' => array(
    'renderer' => 'zf-snap-google-adsense-renderer-view-customview',
  ),
);
```

If you wrote your own renderer pass intance name from `service_manager`. You can also set custom parameters into view. To see how it works look into `renderers` array in `config/module.config.php` and view renderers source.

Options
-------

[](#options)

`ads` defines ad units

- **id** (required): Ad ID,
- **size** (required): You can define size by string or array,
- **type**: content and link. Content unit is default. You can use constats or strings,
- **name**: It's used in custom renderes (placeholdit and html). If name is not defined, ad gets name by key name,

```
return array(
  'zf-snap-google-adsense' => array(
    'ads' => array(
      'link-ad-by-constat' => array(
        'id' => 1234567890,
        'size' => '336x280',
        'type' => \ZfSnapGoogleAdSense\Model\AdUnit::TYPE_LINK,
      ),
      'link-ad-by-string' => array(
        'id' => 1234567890,
        'size' => array(
          'width' => 336,
          'height' => 280,
        ),
        'type' => 'link',
      ),
      'content-ad' => array(
        'id' => 1234567890,
        'size' => '336x280',
        'type' => \ZfSnapGoogleAdSense\Model\AdUnit::TYPE_CONTENT,
        'name' => 'Content ad under header',
      ),
    ),
  ),
);
```

`enable` if equals `false`, than disable ads on page.

```
return array(
  'zf-snap-google-adsense' => array(
    'enable' => false,
  ),
);
```

`publisher-id` (required) publisher ID - you can [find it here](https://www.google.com/adsense/app#accountInformation)

`unit-limit` limits ads on page. Default values:

- 3 content units ([more info](https://support.google.com/adsense/answer/1346295#Google_ad_limit_per_page))
- 3 link units ([more info](https://support.google.com/adsense/answer/1346295#Google_link_unit_limit_per_page))

```
return array(
  'zf-snap-google-adsense' => array(
    'unit-limit' => array(
      AdUnit::TYPE_CONTENT => 3,
      AdUnit::TYPE_LINK => 3,
    ),
  ),
);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4458d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/93a2113828a101b473d256ef12e6bd89d67bcbef0621704cfeb3304c98a16a47?d=identicon)[snapshotpl](/maintainers/snapshotpl)

---

Top Contributors

[![snapshotpl](https://avatars.githubusercontent.com/u/312655?v=4)](https://github.com/snapshotpl "snapshotpl (38 commits)")

---

Tags

googlezf2view helpergoogle adsense

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/snapshotpl-zf-snap-google-adsense/health.svg)

```
[![Health](https://phpackages.com/badges/snapshotpl-zf-snap-google-adsense/health.svg)](https://phpackages.com/packages/snapshotpl-zf-snap-google-adsense)
```

###  Alternatives

[lorenzoferrarajr/lfj-opauth

LfjOpauth is a Zend Framework 2 module that enables support for many authentication providers through the Opauth framework.

2915.4k](/packages/lorenzoferrarajr-lfj-opauth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
