承接 lehelmatyus/adspinner 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

lehelmatyus/adspinner

最新稳定版本:v1.0.4

Composer 安装命令:

composer require lehelmatyus/adspinner

包简介

Rotates randomly between a set of images. takes a JSON object as input.

README 文档

README

Simple PHP library to randomly rotate between ad images (or any linked images).
Displays a new linked image on every page load. It takes a JSON as an input and picks an image randomly from the onoes available

Donate BitcoinCash

BCH Cash: qrt2r4mryq9xu3sgexq2x98m6aza3s6ug5wt3xd22z
BTC: 1PyoztctiBQmonh8UTpvb6ArA1k3jVeWA6

How To add AdSpinner to your php project

Create a composer.json File: Run the following command to initialize a new composer.json file if you don't already have one.

composer init

Add AdSpinner as a dependency

composer require lehelmatyus/adspinner

Verify Composer Installation

composer install

Usage example

Includ in your project

require_once __DIR__ . '/vendor/autoload.php';

Set up JSON for images

// Example JSON:
$ads_json = '{
   "ads": [
       {
           "link": "https://example.com/ad1",
           "image": "https://example.com/ad1.jpg",
           "alt": "Ad 1",
           "width": 300,
           "height": 250
       },
       {
           "link": "https://example.com/ad2",
           "image": "https://example.com/ad2.jpg",
           "alt": "Ad 2",
           "width": 728,
           "height": 90
       },
       {
           "link": "https://example.com/ad3",
           "image": "https://example.com/ad3.jpg",
           "alt": "Ad 3",
           "width": 160,
           "height": 600
       }
   ]
}';

Start Spinning Images!

$ads_json = '{
    "ads": [
        ...
    ]
}';

$ad_spinner = new AdSpinner($ads_json);
echo $ad_spinner->spin();

// print more than one
echo $ad_spinner->spin(2);

Spin with a template

$templateService = new AdSpinnerTemplateService();
// pass your template string
$templateService->setTemplate('<a href="%link%" target="_blank"><img src="%image%" alt="%alt%" width="%width%" height="%height%"></a>');

$ad_spinner = new AdSpinner($ads_json);
echo "<div class='adspinner'>";
echo $ad_spinner->spin(1, $templateService);
echo "</div>";

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-14