定制 apsonex/laravel-stock-image 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

apsonex/laravel-stock-image

Composer 安装命令:

composer require apsonex/laravel-stock-image

包简介

Stock Images

README 文档

README

Laravel Stock Image is a pluggable image search API tool that allows you to query stock images from various providers like Unsplash, Pexels, Pixabay, and also generate placeholder images dynamically.

🚀 Features

  • Supports multiple providers: Unsplash, Pexels, Pixabay, Placeholder
  • Custom API keys per request or config
  • Smart keyword fallback mechanism
  • Random image selection and provider rotation
  • Easy Laravel integration with route and controller
  • Fully testable and extendable architecture

📦 Installation

composer require apsonex/laravel-stock-image

If you're using Laravel 10+, package auto-discovery will register everything automatically.

⚙️ Configuration

Publish the configuration file if needed:

php artisan vendor:publish --tag=laravel-stock-image-config

This will create config/stock-image.php:

return [
    'route' => [
        'enable'     => true,
        'path'       => 'api/ai/tools/stock-images/search',
        'middleware' => [
            // middlewares
        ],
    ],
];

🔌 Routing

The package automatically registers this route when enabled in the config:

POST /stock-image-search

Payload Parameters

Key Type Description
keywords string Comma-separated keywords to search images (required)
random_result boolean Whether to return a random image from results
random_provider boolean Whether to pick a random provider
page int Which page to fetch from provider
cache boolean Whether to cache the result (default: false)
result_limit int Limit number of images result
provider_api_keys array Optional - Override API keys per provider (optional)
placeholder_size string Used only when fallback placeholder is returned e.g. 600x400
placeholder_text string Text to show in placeholder image e.g. Sample Text
placeholder_text_color string Color for placeholder text e.g. #000000
placeholder_bg_color string Background color for placeholder e.g. #cccccc

✅ Example Request (JSON)

POST to /api/ai/tools/stock-images/search

// result
{
  "keywords": "mountain, beach",
  "random_result": true,
  "random_provider": false,
  "page": 1,
  "cache": false,
  "result_limit": 10,
  "provider_api_keys": {
    "pexels": "<PEXELS_API_KEY>",
    "unsplash": "<UNSPLASH_API_KEY>",
    "pixabay": "<PIXABAY_API_KEY>"
  },
  "placeholder_text": "Placeholder Image",
  "placeholder_size": "600x400",
  "placeholder_bg_color": "cccccc",
  "placeholder_text_color": "333333"
}

🔄 Sample JSON Response

{
  "items": [
    {
      "image_url": "https://example.com/image.jpg",
      "image_description": "A stunning mountain landscape",
      "source": "unsplash"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 30,
    "count": 1
  },
  "status": "success"
}

🧪 Testing

You can run tests using Pest:

./vendor/bin/pest

Make sure to mock external APIs to avoid hitting rate limits.

🧠 License

MIT © Apsonex

apsonex/laravel-stock-image 适用场景与选型建议

apsonex/laravel-stock-image 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「apsonex」 「laravel-stock-image」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 apsonex/laravel-stock-image 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 apsonex/laravel-stock-image 我们能提供哪些服务?
定制开发 / 二次开发

基于 apsonex/laravel-stock-image 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-15