Skip to content

davemg3/Adsense-Ads

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adsense Ads for Laravel 5

License Latest Stable Version Total Downloads

Package for easily including Adsense Ad units in Laravel 5.

Installation

In your project root run

composer require mastergalen/adsense-ads

Set up config file

Run php artisan config:publish mastergalen/adsense-ads.

Edit the generated config file in /config/ads.php to add your ad units

return [
    'client_id' => 'YOUR_CLIENT_ID', //Your Adsense client ID e.g. ca-pub-9508939161510421
    'ads' => [
        'responsive' => [
            'ad_unit_id' => 12345678901,
            'ad_format' => 'auto'
        ],
        'rectangle' => [
            'ad_unit_id' => 1234567890,
            'ad_style' => 'display:inline-block;width:300px;height:250px',
            'ad_format' => 'auto'
        ]
    ]
];

Register the package with Laravel

Add the provider to the providers array in your config/app.php file:

Mastergalen\AdsenseAds\AdsServiceProvider::class,

Register an alias:

'Ads' => Mastergalen\AdsenseAds\AdsFacade::class,

Usage

To show ads in your blade templates simply use {!! Ads::show('responsive') !!} , for example.

About

Package for easily including Adsense Ad units in Laravel.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 81.4%
  • HTML 18.6%