pbxg33k / musicbrainz
A PHP library for accessing the MusicBrainz API
Installs: 1 904
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 5
Forks: 41
Open Issues: 5
Requires (Dev)
- guzzlehttp/guzzle: ~5.3
- phpunit/phpunit: ^5.3
Suggests
- guzzle/guzzle: Allows you to use the GuzzleHttpAdapter. You must install one of the supported adapters.
- rmccue/requests: Allows you to use the RequestsHttpAdapter. You must install one of the supported adapters.
Replaces
- mikealmond/musicbrainz: ~0.2
This package is not auto-updated.
Last update: 2024-11-15 21:02:57 UTC
README
MusicBrainz Web Service (v2) PHP class
This PHP library that allows you to easily access the MusicBrainz Web Service V2 API. Visit the MusicBrainz development page for more information.
This project is a fork of https://github.com/mikealmond/MusicBrainz which in turn is a fork of the discontinued project olds/phpbrainz (see the Network Graph). It takes some inspiration from the Python bindings
Installation
install Composer
Download the installer file in your project folder:
wget https://getcomposer.org/installer -O composer-setup.php
Review on Github if you which to know more about the inner workings of the Composer installer. The source is plain PHP. and then
mkdir -p bin
php composer-setup.php --install-dir=bin --filename=composer
Now just run
bin/composer install -vvv
This takes a while. Get a coffe or do some workout. When finished, open one of the examples in your browser: http://localhost/phpbrainz/examples/browse.php
Usage Example
With Guzzle5
(this is the default in our composer.json
)
<?php use Guzzle\Http\Client; use MusicBrainz\Filters\ArtistFilter; use MusicBrainz\Filters\RecordingFilter; use MusicBrainz\HttpAdapters\GuzzleFiveAdapter; use MusicBrainz\MusicBrainz; require __DIR__ . '/vendor/autoload.php'; $brainz = new MusicBrainz(new GuzzleFiveAdapter(new Client()), 'username', 'password'); $brainz->setUserAgent('ApplicationName', '0.2', 'http://example.com'); $args = array( "recording" => "Buddy Holly", "artist" => 'Weezer', "creditname" => 'Weezer', "status" => 'Official' ); try { $recordings = $brainz->search(new RecordingFilter($args)); print_r($recordings); } catch (Exception $e) { print $e->getMessage(); } ?>
With Guzzle3
<?php use Guzzle\Http\Client; use MusicBrainz\Filters\ArtistFilter; use MusicBrainz\Filters\RecordingFilter; use MusicBrainz\HttpAdapters\GuzzleHttpAdapter; use MusicBrainz\MusicBrainz; require __DIR__ . '/vendor/autoload.php'; $brainz = new MusicBrainz(new GuzzleHttpAdapter(new Client()), 'username', 'password'); $brainz->setUserAgent('ApplicationName', '0.2', 'http://example.com'); $args = array( "recording" => "Buddy Holly", "artist" => 'Weezer', "creditname" => 'Weezer', "status" => 'Official' ); try { $recordings = $brainz->search(new RecordingFilter($args)); print_r($recordings); } catch (Exception $e) { print $e->getMessage(); } ?>
Look in the /examples folder for more.
Requirements
- PHP (5.6 or later)
- cURL extension
install withsudo apt-get install php-curl
License
Short: Use it in any project, no matter if it is commercial or not. Just don't remove the copyright notice.
MIT License
Copyright © 2015 Mike Almond
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.