定制 joukhar/laravel-pixabay 二次开发

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

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

joukhar/laravel-pixabay

Composer 安装命令:

composer require joukhar/laravel-pixabay

包简介

Laravel package for accessing the Pixabay API effortlessly.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Overview

LaravelPixabay is a Laravel package that simplifies the process of interacting with the Pixabay API. It provides a way to search and retrieve images and videos from the Pixabay platform with minimal effort. This package includes various customizable options like image/video type, categories, order, page results, and more.

Requirements

Support us

If you find my packages useful, consider buying me a coffee to support further development.

Buy Me A Coffee

Installation

You can install the package via composer:

composer require joukhar/laravel-pixabay

You can publish the config file or add pixabay service to (config/services.php) file:

php artisan vendor:publish --tag="laravel-pixabay-config"

Configuration file (config/pixabay.php):

return [
    'key' => env('PIXABAY_API_KEY'),
];

Then add your Pixabay API key to the .env file:

PIXABAY_KEY=your_pixabay_api_key

Usage

get images

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getImages();

get specific image

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getImages(id:"< IMAGE ID HERE >");

get images with specific type ( Default : PixabayImageType::ALL )

use Joukhar\LaravelPixabay\Enums\PixabayImageType;

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getImages(type: PixabayImageType::ILLUSTRATION );

get videos

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getVideos();

get videos with specific type ( Default : PixabayVideoType::ALL )

use Joukhar\LaravelPixabay\Enums\PixabayVideoType;

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getVideos(type: PixabayVideoType::ANIMATION);

get specific video

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getVideos(id:"< VIDEO ID HERE >");

Customizing API Requests

You can customize your queries using several configuration methods provided by the LaravelPixabay class.

Set Current Page

You can specify which page of results to fetch using setCurrentPage():

$pixabay->setCurrentPage(2);

Set Maximum Results Per Page

The number of results per page can be adjusted using setMaxResults():

$pixabay->setMaxResults(50);

Enable Safe Search

To filter out adult content, use setSafeSearch():

$pixabay->setSafeSearch(true);

Only Editor's Choice

You can request only editor's choice images or videos using setOnlyEditorChoice():

$pixabay->setOnlyEditorChoice(true);

Set Category

To fetch resources of a specific category, use setCategory():

use Joukhar\LaravelPixabay\Enums\PixabayCategory;

$pixabay->setCategory(PixabayCategory::NATURE);

Set Order

To order results by popularity, latest, or custom order, use setOrder():

$pixabay->setOrder('latest');

Set Minimum Dimensions

You can set the minimum width and height for the images/videos to be returned using setDimentions():

$pixabay->setDimentions(800, 600);

Example: Fetching Nature Photos

use Joukhar\LaravelPixabay\LaravelPixabay;
use Joukhar\LaravelPixabay\Enums\PixabayCategory;
use Joukhar\LaravelPixabay\Enums\PixabayImageType;

$pixabay = new LaravelPixabay();
$photos = $pixabay
    ->setCategory(PixabayCategory::NATURE)
    ->setMaxResults(10)
    ->setSafeSearch(true)
    ->getImages(null, PixabayImageType::PHOTO);

Exception Handling

If there is an issue with the API request (e.g., invalid API key, request failure), the package throws an Exception with a detailed error message.

try {
    $images = $pixabay->getImages();
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

joukhar/laravel-pixabay 适用场景与选型建议

joukhar/laravel-pixabay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-21