PHP code example of calliostro / discogs-bundle

1. Go to this page and download the library: Download calliostro/discogs-bundle 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/ */

    

calliostro / discogs-bundle example snippets




namespace App\Controller;

use Calliostro\Discogs\DiscogsClient;
use Symfony\Component\HttpFoundation\JsonResponse;

final class MusicController
{
    public function artistInfo(string $id, DiscogsClient $client): JsonResponse
    {
        $artist = $client->getArtist(artistId: (int) $id);
        $releases = $client->listArtistReleases(artistId: (int) $id, perPage: 5);

        return new JsonResponse([
            'artist' => $artist['name'],
            'profile' => $artist['profile'] ?? null,
            'releases' => $releases['releases'],
        ]);
    }
}

// Requires Personal Access Token
$collection = $client->listCollectionItems(username: 'your-username', folderId: 0);
$wantlist = $client->getUserWantlist(username: 'your-username');

$client->addToCollection(
    username: 'your-username',
    folderId: 1,
    releaseId: 30359313
);

$client->addToWantlist(
    username: 'your-username',
    releaseId: 28409710
);

$results = $client->search(
    q: 'Billie Eilish',
    type: 'artist'
);

$releases = $client->listArtistReleases(artistId: 4470662);
$release = $client->getRelease(releaseId: 30359313);
$master = $client->getMaster(masterId: 2835729);
$label = $client->getLabel(labelId: 12677);