PHPackages                             leonardcodep/laravel-adsbygoogle - 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. [Framework](/categories/framework)
4. /
5. leonardcodep/laravel-adsbygoogle

ActiveLibrary[Framework](/categories/framework)

leonardcodep/laravel-adsbygoogle
================================

Display Google Adsense ads in your Laravel.

1.0.2(5y ago)136MITPHPPHP ^7.2

Since May 4Pushed 5y agoCompare

[ Source](https://github.com/leonardcodep/laravel-adsbygoogle)[ Packagist](https://packagist.org/packages/leonardcodep/laravel-adsbygoogle)[ Docs](https://github.com/leonardcodep/laravel-adsbygoogle)[ RSS](/packages/leonardcodep-laravel-adsbygoogle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Adsense for Laravel 5, 6, 7 y 8
===============================

[](#adsense-for-laravel-5-6-7-y-8)

Package to include Google Adsense ads in your Laravel project.

Installation
------------

[](#installation)

In your project root run

```
composer require leonardcodep/laravel-adsbygoogle

```

### Set up config file

[](#set-up-config-file)

Run `php artisan vendor:publish --provider="Leonardcodep\Adsbygoogle\AdsbygoogleServiceProvider" --tag="config"`.

Run (Optional) `php artisan vendor:publish --provider="Leonardcodep\Adsbygoogle\AdsbygoogleServiceProvider" --tag="views"`.

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

```
return [
    'client_id' => 'YOUR_CLIENT_ID', //Your Adsense client ID e.g. ca-pub-9508939161510421
    'ads' => [
        'responsive' => [
            'ad_slot' => 12345678901,
            'ad_format' => 'auto',
            'ad_full_width_responsive' => true
        ],
        'rectangle' => [
            'ad_slot' => 5681560223,
            'ad_style' => 'display:inline-block;width:300px;height:250px',
        ],
        'inArticle' => [
            'ad_layout' => 'in-article',
            'ad_format' => 'fluid',
            'ad_slot' => 5149408889,
            'ad_style' => 'display:block; text-align:center;'
        ]
    ]
];
```

### Register the package with Laravel

[](#register-the-package-with-laravel)

This package is for Laravel 5.5+ so it takes advantage of auto discover, so no manual configuration is needed

Usage
-----

[](#usage)

1°- Copy and paste this code into your website's HTML, between the ` and ` tags.

```
    @scriptadsbygoogle
```

Show directive

```

```

2°- (Optional) Copy and paste this code into your website's HTML, between the ` and ` tags.

```
    @anchoradsbygoogle
```

Show directive

```

        (adsbygoogle = window.adsbygoogle || []).push({
            google_ad_client: "CLIENT_ID",
            enable_page_level_ads: true,
            overlays: {bottom: true}
        });
