PHP code example of lachlan-00 / musicbrainz

1. Go to this page and download the library: Download lachlan-00/musicbrainz library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lachlan-00 / musicbrainz example snippets



    use MusicBrainz\MusicBrainz;
    
    f you want)
    $config = [
        'allow_redirects' => true,
        'verify' => false,
    ];
    
    // Some areas null, $config);
    $brainz->setUserAgent('ApplicationName', MusicBrainz::VERSION, 'https://example.com');
    
    try {
        // Search for recordings and then return a list of Recording objects
        $args = [
            'recording' => 'Buddy Holly',
            'artist' => 'Weezer',
            'creditname' => 'Weezer',
            'status' => 'Official'
        ];
    
        /**
         * Search will return objects by default which are arrays of data
         * @var array $recordings
         */
        $recordings = $brainz->search(
            MusicBrainz::newFilter('recording', $args)
        );
        foreach ($recordings as $recording) {
            print('RECORDING ' . $recording->getId() . "\n");
            print_r($recording->getData());
        }
    } catch (Exception $e) {
        print $e->getMessage();
        die();
    }
    
    
    try {
        // Look up the artist for a recording and print the Artist object data
        $