PHPackages                             martinbutt/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. martinbutt/laravel-adsense

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

martinbutt/laravel-adsense
==========================

Display Adsense ads easily in Laravel 6.x, 7.x and 8.x

v2.0.1(4y ago)101.0k4MITPHPPHP ^7.2||^8.0

Since Jul 1Pushed 4y agoCompare

[ Source](https://github.com/martinbutt/laravel-adsense)[ Packagist](https://packagist.org/packages/martinbutt/laravel-adsense)[ RSS](/packages/martinbutt-laravel-adsense/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (4)Versions (15)Used By (0)

Google Adsense Ads for Laravel 6.x, 7.x and 8.x
===============================================

[](#google-adsense-ads-for-laravel-6x-7x-and-8x)

[![Latest Version](https://camo.githubusercontent.com/7342d44b21d407e384a80b311757ab36b0d25efcf8c52deecb9ade90a8a7795e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617274696e627574742f6c61726176656c2d616473656e73652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martinbutt/laravel-adsense)[![Total Downloads](https://camo.githubusercontent.com/4c07b2cbfceeaf4e2ac612c59c342301fd10c99ef03910845b6b2a0514f153e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617274696e627574742f6c61726176656c2d616473656e73652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martinbutt/laravel-adsense)[![Build Status](https://camo.githubusercontent.com/8ccce8bea72988a4431ef0e7b5e65486b7bbcde3e9c2c62ebd28a94cf29a7377/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d617274696e627574742f6c61726176656c2d616473656e73652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/martinbutt/laravel-adsense)[![StyleCI](https://camo.githubusercontent.com/539a098b4e60d2c0f84a9b74d1727e296933d1b1b0120988b38c244b43b07700/68747470733a2f2f7374796c6563692e696f2f7265706f732f3335393034353630342f736869656c643f7374796c653d666c61742d737175617265)](https://styleci.io/repos/359045604)[![Scrutinizer](https://camo.githubusercontent.com/d0e236c292364327b081cab02a721dc12eb4269c067a1ecea42b597dabcfda33/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617274696e627574742f6c61726176656c2d616473656e73652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/martinbutt/laravel-adsense/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f0dbb570c7066e12ac9218776a9865636cd909e167cc65dec69d1f7fe5e37444/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617274696e627574742f6c61726176656c2d616473656e73652f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/martinbutt/laravel-adsense)[![License](https://camo.githubusercontent.com/60fc38184d7b971b525b7903f55b65a4ec46255d77518c5716965328f6c317fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d617274696e627574742f6c61726176656c2d616473656e73653f7374796c653d666c61742d737175617265)](LICENSE.md)

Package for easily including Google Adsense Ad units in [Laravel 6.x, 7.x and 8.x](https://laravel.com) and [Lumen](https://lumen.laravel.com). For use with Laravel 5.x use original [Mastergalen/Adsense-Ads package](https://github.com/Mastergalen/Adsense-Ads).

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

[](#installation)

### 1 - Dependency

[](#1---dependency)

In your project root run

The first step is using [Composer](https://getcomposer.org) to install the package and automatically update your `composer.json` file, you can do this by running:

```
composer require martinbutt/laravel-adsense
```

### 2 - Set up config file

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

Run `php artisan config:publish martinbutt/laravel-adsense`.

Edit the generated config file in `/config/adsense.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' => 1111111111,
            'ad_format' => 'fluid',
            'ad_full_width_responsive' => true,
            'ad_style' => 'display:inline-block'
        ],
        'rectangle' => [
            'ad_slot' => 2222222222,
            'ad_style' => 'display:inline-block;width:300px;height:250px',
            'ad_full_width_responsive' => false,
            'ad_format' => 'auto'
        ]
    ]
];
```

### 3 - Register the provider with Laravel

[](#3---register-the-provider-with-laravel)

You need to update your application configuration in order to register the package so it can be loaded by Laravel, just update your `config/app.php` file adding the following code at the end of your `'providers'` section:

> `config/app.php`

```
