Download the PHP package xenos/musicbrainz without Composer
On this page you can find all versions of the php package xenos/musicbrainz. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xenos/musicbrainz
More information about xenos/musicbrainz
Files in xenos/musicbrainz
Package musicbrainz
Short Description A PHP library for accessing the MusicBrainz API
License MIT
Homepage https://github.com/XenosEleatikos/MusicBrainz
Informations about the package musicbrainz
MusicBrainz API Client
This project contains an easy to use PHP API client for the MusicBrainz JSON web service.
Contents
- Installation
- Install with Git
- Install with Composer
- Set up
- HTTP Adapter
- Logger
- MusicBrainz Credentials
- Usage
- Search Requests
- Lookup Requests
- Browse Requests
Installation
Install with Git
Install with Composer
This project is available at Packagist: https://packagist.org/packages/xenos/musicbrainz.
You can use it in your project with the following command:
Set up
HTTP Adapter
As an HTTP client is necessary to the the MusicBrainz API client, you have to provide it as constructor argument. You may use any HTTP client by using an adapter instantiating . This projects delivers an adapter for Guzzle 6, but you may write your own adapter for your preferred HTTP client.
Usage with Guzzle:
Don't forget to add Guzzle
to your composer project, if not yet required.
Logger
Optionally, you may set any PSR-3 logger implementing by injecting it as a second constructor argument.
Usage with Guzzle and Monolog:
Don't forget to add Monolog
to your composer project, if not yet required.
MusicBrainz Credentials
All requests for user-tags
or user-ratings
require authentication.
Custom API Path
By default, all requests are executed against the MusicBrainz API at https://musicbrainz.org/ws/2. You can set another base path (e. g. for your own MusicBrainz installation) as follows:
Usage
Search Requests
The search API provides methods to search for the MusicBrainz core entities. For each of these entities there is a search method taking a specific filter object and a page filter for pagination. The return value will be a specific list object containing basic information about the matching entities. For more information you have to perform a lookup request with the MusicBrainz Identifier (MBID) of the entity.
The following example search for the artist named "Tom Waits" and limits the result list to the top match.
Lookup Requests
If you have the MusicBrainz Identifier (MBID) of an entity (through a search request), you can get more information about it by performing a lookup request. For each of the core entities there is a specific lookup method. As first argument you have to pass the MBID. The second argument is a list of additional fields the response object should contain.
The followig example looks up for the artist with MBID c3aeb863-7b26-4388-94e8-5a240f2be21b (who is Tom Waits), and requests to append information about his his recordings and works to the response.
Browse Requests
Browse requests are a direct lookup of all the entities directly linked to another entity with a given MusicBrainz Identifier (MBID).
The following example looks up for all events directly linked to the artist with the MBID c3aeb863-7b26-4388-94e8-5a240f2be21b (who is Tom Waits). In analogy to normal lookup requests additional fields may be specified for the response, and a page filter may be added for pagination.