PHPackages                             monkeyphp/music-brainz - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. monkeyphp/music-brainz

ActiveLibrary[API Development](/categories/api)

monkeyphp/music-brainz
======================

Client library for accessing MusicBrainz api

023PHP

Since Mar 22Pushed 12y ago1 watchersCompare

[ Source](https://github.com/monkeyphp/music-brainz)[ Packagist](https://packagist.org/packages/monkeyphp/music-brainz)[ RSS](/packages/monkeyphp-music-brainz/feed)WikiDiscussions develop Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

MusicBrainz
===========

[](#musicbrainz)

Client library for accessing the MusicBrainz Api.

[![Build Status](https://camo.githubusercontent.com/c24494be255a9ca6d95dcc68c5ce1a963413d60ae842049c72a88e721de999ff/68747470733a2f2f7472617669732d63692e6f72672f6d6f6e6b65797068702f6d757369632d627261696e7a2e706e673f6272616e63683d646576656c6f70)](https://travis-ci.org/monkeyphp/music-brainz)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/10a90305f2a8ed2e80f019225e8cfcc1515f72d681ea17a668eb4e2201ec30e6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6f6e6b65797068702f6d757369632d627261696e7a2f6261646765732f7175616c6974792d73636f72652e706e673f733d38613466663436613066656361623638663964373633613265353065333162643833353030666330)](https://scrutinizer-ci.com/g/monkeyphp/music-brainz/)[![Code Coverage](https://camo.githubusercontent.com/786111c7cf9eafaa5b0e61c1df940954510b367b163ba439f15619e7471e681d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6f6e6b65797068702f6d757369632d627261696e7a2f6261646765732f636f7665726167652e706e673f733d62376637616331363062333266333664326439646336363139383463303163346530626366336333)](https://scrutinizer-ci.com/g/monkeyphp/music-brainz/)[![Latest Stable Version](https://camo.githubusercontent.com/ba652a5f3b43bbe76468e72fc447261dad83ccfd2e9f45798646a0f5cb6b9509/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e6b65797068702f6d757369632d627261696e7a2f762f737461626c652e706e67)](https://packagist.org/packages/monkeyphp/music-brainz)[![Total Downloads](https://camo.githubusercontent.com/61d5233fcd4da48c1324f9b5feef24e5860e2a14883a21b6daa1e5f34ca8b1e2/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e6b65797068702f6d757369632d627261696e7a2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/monkeyphp/music-brainz)[![Latest Unstable Version](https://camo.githubusercontent.com/56116c3873e27917c2506f835372b7e35fc24a6ba2d41a82ce20e46a61beb448/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e6b65797068702f6d757369632d627261696e7a2f762f756e737461626c652e706e67)](https://packagist.org/packages/monkeyphp/music-brainz)[![License](https://camo.githubusercontent.com/d9b3902e1e34fe7ed3d506c96242ca75ab587ffdee5ef10b8b2e51c4487eecc3/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e6b65797068702f6d757369632d627261696e7a2f6c6963656e73652e706e67)](https://packagist.org/packages/monkeyphp/music-brainz)

Links
-----

[](#links)

[http://musicbrainz.org/doc/Development/XML\_Web\_Service/Version\_2](http://musicbrainz.org/doc/Development/XML_Web_Service/Version_2)

Get the MusicBrainz Library
---------------------------

[](#get-the-musicbrainz-library)

The easiest way to get the library is to use [Composer](https://getcomposer.org/)and [Packagist](http://packagist.org/).

If you do not already have Composer in your application, you can install it as follows.

```
$ curl -sS https://getcomposer.org/installer | php

```

Create the `composer.json` file.

```
$ touch composer.json

```

Add the following to the `composer.json` file

```
{
    "require": {
        "monkeyphp/music-brainz" "*"
    }
}

```

Finally run Composer install

```
$ php composer.phar install

```

You should now have the library installed into your `vendors` directory.

Autoloading the MusicBrainz Library
-----------------------------------

[](#autoloading-the-musicbrainz-library)

The easiest way to start using MusicBrainz is to use the Composer autoloader.

Include the Composer autoloader into your script

```
require_once "vendor/autoload.php";

```

Create an instance of MusicBrainz
---------------------------------

[](#create-an-instance-of-musicbrainz)

### Identity

[](#identity)

The MusicBrainz.org api expects that client applications should identity themselves using the `User-Agent` header.

To support this requirement, this MusicBrainz library utilizes a simple Identity class. The class requires a single constructor parameter; the name that your application will use to identity itself to the MusicBrainz.org api.

```
$identity = new Identity('my_application');

```

You may also, optionally supply a version number for your application, and a contact detail so that the MusicBrainz.org administrators may contact you should they need to.

```
$identity = new Identity('my_application', 1.1, 'contact@example.com');

```

To create an instance of MusicBrainz, you must supply either; an instance of Identity, a single string or an associative array of values.

### Examples

[](#examples)

Create a MusicBrainz instance supplying an Identity instance

```
$identity = new Identity('my_application', 1.0, 'contact@example.com');
$musicBrainz = new MusicBrainz($identity);

```

Create a MusicBrainz instance by supplying a string

```
$musicBrainz = new MusicBrainz('my_application');

```

Create a MusicBrainz instance by supplying an array of Identity values

```
$musicBrainz = new MusicBrainz(array('my_application', 1.0, 'contact@example.com')

```

Once you have your MusicBrainz instance you may now start querying the MusicBrainz.org api.

Resources
---------

[](#resources)

MusicBrainz provides the following resources

- Artist `artist`
- Label `label`
- Recording `recording`
- Release `release`
- Release Group `release-group`
- Work `work`
- Area `area`
- Url `url`

For each of these resources, you can perform three actions;

- Search
- Lookup
- Browse

### Search a Resource

[](#search-a-resource)

Searching for a resource requires two parameters and accepts a third optional parameter;

- The resource type **(required)**
    - Accepted values may be one of the following:
        - `artist` or `ConnectorInterface::RESOURCE_ARTIST`
        - `label` or `ConnectorInterface::RESOURCE_LABEL`
        - `recording` or `ConnectorInterface::RESOURCE_RECORDING`
        - `release` or `ConnectorInterface::RESOURCE_RELEASE`
        - `release-group` or `ConnectorInterface::RESOURCE_RELEASE_GROUP`
        - `work` or `ConnectorInterface::RESOURCE_WORK`
        - `area` or `ConnectorInterface::RESOURCE_AREA`
        - `url` or `ConnectorInterface::RESOURCE_URL`
- A [Lucene](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html) compatible query string **(required)**
- An array of additional options **(optional)**
    - The accepted keys and values are as follows:
        - `format` - a value of `xml`, `json`, `ConnectorInterface::FORMAT_XML` or `ConnectorInterface::FORMAT_JSON`
        - `limit` - an integer value between `1` and `100`
        - `offset` - an integer of `0` or above

Searching for a resource will return an instance of a resource specific Search entity

```
// returns an instance of ArtistSearch
$artistSearch = $musicBrainz->search('artist', 'metallica');
// or
$artistSearch = $musicBrainz->search(
    ConnectorInterface::RESOURCE_ARTIST,
    'pixies',
    array(
        'format' => ConnectorInterface::FORMAT_XML
        'offset' => 0,
        'limit' => 10,
    )
);

// returns an instance of LabelSearch
$labelSearch = $musicBrainz->search('label', 'parlaphone');
// or
$labelSearch = $musicBrainz->search(ConnectorInterface::RESOURCE_LABEL, 'decca');

// returns an instance of AreaSearch
$areaSearch = $musicBrainz->search('area', 'Los Angeles');
// or
$areaSearch = $musicBrainz->seearch(ConnectorInterface::RESOURCE_AREA, 'New York, US');

```

### Lookup a Resource

[](#lookup-a-resource)

Lookup queries are a way of retrieving additional information about a resource. Performing a lookup of a resource is very similar to performing a search, but with a very crucial difference. When you lookup a resource, you already know the **Mbid** of the resource and supply that in the lookup query.

Performaing a lookup for a resource requires the resource type that you are looking up, the **Mbid** of that resource and an optional array of options.

- The resource type **(required)**
    - Accepted values may be one of the following:
        - `artist` or `ConnectorInterface::RESOURCE_ARTIST`
        - `label` or `ConnectorInterface::RESOURCE_LABEL`
        - `recording` or `ConnectorInterface::RESOURCE_RECORDING`
        - `release` or `ConnectorInterface::RESOURCE_RELEASE`
        - `release-group` or `ConnectorInterface::RESOURCE_RELEASE_GROUP`
        - `work` or `ConnectorInterface::RESOURCE_WORK`
        - `area` or `ConnectorInterface::RESOURCE_AREA`
        - `url` or `ConnectorInterface::RESOURCE_URL`
- The Mbid of the resource **(required)**
- An array of additional options **(optional)**

Lookups will return a resource specific Lookup entity

```
// returns an instance of ArtistLookup
$artistLookup = $musicBrainz->lookup('artist', '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab');

```

Generate Unit tests with Codeception
------------------------------------

[](#generate-unit-tests-with-codeception)

```
$ vendor/bin/codecept generate:phpunit unit MusicBrainzTest/Entity/Alias

```

Run the Codeception unit tests
------------------------------

[](#run-the-codeception-unit-tests)

```
$ vendor/bin/codecept run unit

```

Include output report

```
$ vendor/bin/codecept run unit --coverage --html

```

License
-------

[](#license)

Copyright (C) 2014 David White

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see \[\].

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc2ab20dc9cef0e2318a63df0ab2407c5914beb0cca5095443d3fe477dc17cce?d=identicon)[MonkeyPHP](/maintainers/MonkeyPHP)

---

Top Contributors

[![monkeyphp](https://avatars.githubusercontent.com/u/1448153?v=4)](https://github.com/monkeyphp "monkeyphp (188 commits)")

### Embed Badge

![Health badge](/badges/monkeyphp-music-brainz/health.svg)

```
[![Health](https://phpackages.com/badges/monkeyphp-music-brainz/health.svg)](https://phpackages.com/packages/monkeyphp-music-brainz)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
