stephan-strate / php-cover-art-archive-api
PHP wrapper for CoverArtArchive api. Supports object-oriented access using repositories and factories.
Fund package maintenance!
stephan-strate
Requires
- php: ^7.4 || ^8.0
- ext-gd: *
- ext-json: *
- doctrine/annotations: ^1.11
- php-http/client-common: ^2.3
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.10
- php-http/httplug: ^2.2
- symfony/property-access: ^5.2
- symfony/serializer: ^5.2
Requires (Dev)
- guzzlehttp/guzzle: ^7.2
- guzzlehttp/psr7: ^1.2 || ^2.0
- http-interop/http-factory-guzzle: ^1.0
- php-http/mock-client: ^1.4.1
- phpstan/phpstan: ^0.12.75 || ^1.0.0
- phpunit/phpunit: ^9.3
- dev-master
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.0.3-alpha
- v0.0.2-alpha
- v0.0.1-alpha
- dev-dependabot/composer/phpstan/phpstan-1.10.11
- dev-dependabot/composer/symfony/property-access-5.4.22
- dev-dependabot/composer/phpunit/phpunit-9.6.6
- dev-dependabot/composer/doctrine/annotations-2.0.1
- dev-dependabot/composer/php-http/client-common-2.6.0
This package is auto-updated.
Last update: 2024-12-04 23:44:32 UTC
README
CoverArtArchive API Wrapper
CoverArtArchive is a joint project between the Internet Archive and MusicBrainz. Goal of this project is to make cover art images available to everyone.
Using this api wrapper, you can retrieve cover art images using the release MBID of MusicBrainz.
Recommended to use together with stephan-strate/php-music-brainz-api.
Inspired by php-github-api and php-tmdb.
Installation
Using composer:
$ composer require stephan-strate/php-cover-art-archive-api php-http/guzzle7-adapter:^1.0 http-interop/http-factory-guzzle:^1.0
Why php-http/guzzle7-adapter:^1.0
? This library is decoupled from any http client using HTTPlug.
Usage
First you want to create the client:
$client = new \CoverArtArchive\Client();
Using this client, you can retrieve all other objects/apis.
Repository
The repository implementation takes the decoded json response and maps it to a matching model. This is the preferred way of using the library.
$repository = new \CoverArtArchive\Repository\ReleaseGroupRepository($client); $repository->coverArt('19e6209b-2ddc-30b8-9273-484bd075fe7b');
Images
As the CoverArtArchive serves, as the name implies, images. Therefore the repository can also return image resources.
$repository = new \CoverArtArchive\Repository\ReleaseRepository($client); $image = $repository->coverArtFront('7416e707-94b5-3810-b6b8-4229ab2182ec'); // outputs the image to the user if ($image !== false) { header('Content-Type: image/png'); imagepng($image); imagedestroy($image); }
Api
The api implementation returns the raw json response of the endpoint. You might want to use the repository implementation instead to get the parsed objects.
$release = $client->release(); $release->coverArt('7416e707-94b5-3810-b6b8-4229ab2182ec');
Contributing
Help & Donate
I am very curious about projects that use my libraries. Please drop me a short message about what you use the library for. You can find my contact information on my profile (LinkedIn, E-mail).
If this project saved you time and money or you just appreciate what I am doing, please consider sponsoring me 😊