leonardcodep/laravel-adsbygoogle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leonardcodep/laravel-adsbygoogle

Composer 安装命令:

composer require leonardcodep/laravel-adsbygoogle

包简介

Display Google Adsense ads in your Laravel.

README 文档

README

Package to include Google Adsense ads in your Laravel project.

Installation

In your project root run

composer require leonardcodep/laravel-adsbygoogle

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

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

Usage

1°- Copy and paste this code into your website's HTML, between the <head> and </head> tags.

    @scriptadsbygoogle

Show directive

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=CLIENT_ID" crossorigin="anonymous"></script>

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

    @anchoradsbygoogle

Show directive

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

3°- Copy and paste this code into your website's HTML, at the end before closing the and </body> tag.

    @pushadsbygoogle

Show directive

<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

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

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固