Skip to content

elmariachi111/NodrewDfpBundle

 
 

Repository files navigation

Google DFP Bundle for Symfony2 Travis-CI Build Status

Installation Instructions

  1. Download NodrewDfpBundle
  2. Configure the Autoloader
  3. Enable the Bundle
  4. Add your Google DFP Publisher Id

Step 1: Download NodrewDfpBundle

Ultimately, the NodrewDfpBundle files should be downloaded to the vendor/bundles/Nodrew/Bundle/DfpBundle directory.

This can be done in several ways, depending on your preference. The first method is the standard Symfony2 method.

Using the vendors script

Add the following lines in your deps file:

[NodrewDfpBundle]
    git=http://github.com/nodrew/NodrewDfpBundle.git
    target=/bundles/Nodrew/Bundle/DfpBundle

Now, run the vendors script to download the bundle:

$ php bin/vendors install

Using submodules

If you prefer instead to use git submodules, then run the following:

$ git submodule add http://github.com/nodrew/NodrewDfpBundle.git vendor/bundles/Nodrew/Bundle/DfpBundle
$ git submodule update --init

Step 2: Configure the Autoloader

// app/autoload.php

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
    // ...
    'Nodrew'   => __DIR__.'/../vendor/bundles',
));

Step 3: Enable the bundle

Finally, enable the bundle in the kernel:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Nodrew\Bundle\DfpBundle\NodrewDfpBundle(),
    );
}

Step 4: Add your Google DFP Publisher Id

# app/config/config.yml
nodrew_dfp:
    publisher_id:   [publisher_id]

Step 5: Add Control Code Placeholder to layout

This placeholder comment needs to be added to the head of your layout. It is automatically replaced with the proper Google DFP code, when ads are used on the given page.

// app/views/base.html.twig
<head>
    ...
    <!-- NodrewDfpBundle Control Code -->
</head>

Using Ad Units

In page unit.

To use a standard in page ad unit, add the following to your template:

{{ dfp_ad_unit('some/campaign', [300, 250]) }}

The appropriate control codes will be added to the header, if everything was done correctly during setup.

Out of page unit.

If you're looking to do a DFP out of page unit, such as an interstitial, or a skin, then use this code. It is much similar, just without the size attached to it.

{{ dfp_oop_ad_unit('some/campaign') }}

The appropriate control codes will be added to the header, if everything was done correctly during setup.

About

Symfony2 Bundle for integrating with the Google DFP Ad Network

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%