- Download NodrewDfpBundle
- Configure the Autoloader
- Enable the Bundle
- Add your Google DFP Publisher Id
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
// app/autoload.php
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
// ...
'Nodrew' => __DIR__.'/../vendor/bundles',
));
Finally, enable the bundle in the kernel:
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Nodrew\Bundle\DfpBundle\NodrewDfpBundle(),
);
}
# app/config/config.yml
nodrew_dfp:
publisher_id: [publisher_id]
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>
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.
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.