rabol / laravel-adsense
在您的Laravel应用中显示Adsense广告。
v1.0.2
2023-03-04 09:19 UTC
Requires
- php: ^7.2|^7.3|^8.0|^8.1|^8.2
This package is auto-updated.
Last update: 2024-09-04 12:21:20 UTC
README
用于在Laravel 5, 6, 7, 8中包含Adsense广告的包
安装
在项目根目录中运行
composer require rabol/laravel-adsense
设置配置文件
运行 php artisan vendor:publish
。
编辑在 /config/adsense.php
中生成的配置文件以添加广告单元
return [ 'client_id' => 'YOUR_CLIENT_ID', //Your Adsense client ID e.g. ca-pub-9508939161510421 'ads' => [ 'responsive' => [ 'ad_unit_id' => 12345678901, 'ad_format' => 'auto' 'ad_full_width_responsive' => true ], 'rectangle' => [ 'ad_unit_id' => 1234567890, 'ad_style' => 'display:inline-block;width:300px;height:250px', 'ad_format' => 'auto' ] ] ];
在Laravel中注册该包
此包适用于Laravel 5.5+,因此它利用了自动发现,因此不需要手动配置
用法
要在blade模板中显示广告,只需使用 {!! Adsense::show('responsive') !!}
,例如。