ampache/php-discogs-api
Composer 安装命令:
composer require ampache/php-discogs-api
包简介
A PHP library for accessing the Discogs API
README 文档
README
This library is a simple Discogs query library exported from the Ampache Discogs plugin.
The focus here is on keeping it small and simple.
All data is JSON decoded with objects converted into associative arrays.
Requirements
- PHP8.2+
- rmccue/requests
Usage Example
<?php use AmpacheDiscogs\Discogs; require dirname(__DIR__) . '/vendor/autoload.php'; $media = [ [ 'album' => 'The Shape', 'albumartist' => 'Code 64', ], ]; echo "Checking: " . print_r($media, true) . PHP_EOL; try { // your own username and password are required to use the Discogs API $username = 'username'; $password = 'password'; $discogs = new Discogs($username, $password); /** * https://api.discogs.com/database/search?type=master&release_title=The+Shape&artist=Code+64&per_page=10&key=key@secret=secret */ $albums = $discogs->search_album($media['albumartist'], $media['album']); if (empty($albums['results'])) { $albums = $discogs->search_album($media['albumartist'], $media['album'], 'release'); } // get the album that matches $artist - $album if (!empty($albums['results'])) { foreach ($albums['results'] as $albumSearch) { if ($media['albumartist'] . ' - ' . $media['album'] === $albumSearch['title']) { /** * @var array{ * country: string, * year: string, * format: string[], * label: string[], * type: string, * genre: string[], * style: string[], * id: ?int, * barcode: string[], * master_id: int, * master_url: string, * uri: string, * catno: string, * title: string, * thumb: string, * cover_image: string, * resource_url: string, * community: object, * format_quantity: ?int, * formats: ?object, * } $albumSearch */ $album = $albumSearch; break; } } // look up the master release if we have one or the first release if (!isset($album['id'])) { /** * @var array{ * id: ?int, * main_release: int, * most_recent_release: int, * uri: string, * versions_uri: string, * main_release_uri: string, * most_recent_release_uri: string, * num_for_sale: int, * lowest_price: int, * images: object, * genres: string[], * styles: string[], * year: int, * tracklist: object, * artists: object, * title: string, * data-quality: string, * videos: object, * } $album */ $album = (($albums['results'][0]['master_id'] ?? 0) > 0) ? $discogs->get_album((int)$albums['results'][0]['master_id']) : $discogs->get_album((int)$albums['results'][0]['id'], 'releases'); } // fallback to the initial search if we don't have a master if (!isset($album['id'])) { $album = $albums['results'][0]; } print_r($album); } } catch (Exception $exception) { print_r($exception->getMessage()); }
Look in the /examples folder for more.
ampache/php-discogs-api 适用场景与选型建议
ampache/php-discogs-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.33k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「library」 「discogs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ampache/php-discogs-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ampache/php-discogs-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ampache/php-discogs-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
统计信息
- 总下载量: 11.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-30