Download the PHP package martinbutt/laravel-adsense without Composer
On this page you can find all versions of the php package martinbutt/laravel-adsense. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download martinbutt/laravel-adsense
More information about martinbutt/laravel-adsense
Files in martinbutt/laravel-adsense
Package laravel-adsense
Short Description Display Adsense ads easily in Laravel 6.x, 7.x and 8.x
License MIT
Informations about the package laravel-adsense
Google Adsense Ads for Laravel 6.x, 7.x and 8.x
Package for easily including Google Adsense Ad units in Laravel 6.x, 7.x and 8.x and Lumen. For use with Laravel 5.x use original Mastergalen/Adsense-Ads package.
Installation
1 - Dependency
In your project root run
The first step is using Composer to install the package and automatically update your composer.json
file, you can do this by running:
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
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
Lumen
Go to bootstrap/app.php
file and add this line:
4 - Register the alias with Laravel
Note: facades are not supported in Lumen.
You may get access to the Google Adsense Ads services using following facades:
MartinButt\Laravel\Adsense\Facades\AdsenseFacade
You can setup a short-version aliases for these facades in your config/app.php
file. For example:
5 - Configuration
Publish config
In your terminal type
or
Lumen does not support this command, for it you should copy the file
src/resources/config/adsense.php
toconfig/adsense.php
of your project.
In adsense.php
configuration file you can determine the properties of the default values and some behaviors.
Usage
Add {!! Adsense::javascript() !!}
in your <head>
tag.
To show ads, add {!! Adsense::ads('ads_unit') !!}
, where ads_unit
is one of your ads units in your config file (for example {!! Adsense::ads('responsive') !!}
).
Use {!! Adsense::ads('ads_unit') !!}
every time you want to show an ad.
Changelog
Please see the CHANGELOG.md file for more information on what has changed recently.
Credits
- Martin Butt
- Crypto Technology srl
- Luca Bognolo
- All Contributors
License
The Google Adsense Ads is open-sourced software licensed under the MIT license.
Please see the LICENSE.md file for more information.