Skip to content

calliostro/discogs-bundle-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Discogs Bundle Demo

⚠️ DEMO APPLICATION NOTICE
This is a demonstration application for educational and testing purposes only. NOT intended for production use.
Please respect Discogs' terms of service and implement proper caching to avoid overloading their API servers.
For production applications, ensure you comply with Discogs API Guidelines.

This is a comprehensive demo of the calliostro/discogs-bundle
in combination with hwi/HWIOAuthBundle.

You need PHP 8.1–8.5 and Symfony 6.4 (LTS), 7.x, or 8.0 (beta).

Features

πŸ” Search – Search the entire Discogs database
πŸ‘€ User Profiles – View complete user profiles with statistics
πŸ“€ Collections – Browse user collections with detailed information
πŸ’ Wantlists – View and manage Discogs wantlists
🎡 Artist Details – Comprehensive artist information with discography
πŸ’Ώ Release Details – Complete release information including tracklists
🏷️ Label Information – Detailed label profiles and releases
πŸ“‹ User Lists – Custom user-created lists and list items
πŸ›’ Marketplace – Browse marketplace listings and inventory
πŸ“¦ Orders – View and manage marketplace orders
🎲 Random Discovery – Discover random releases from popular artists

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Open a command console, enter your desired parent directory for the demo, and execute:

git clone https://github.com/calliostro/discogs-bundle-demo
cd discogs-bundle-demo
composer install --no-interaction

The lock files (composer.lock, symfony.lock) are not included in this repository to ensure maximum flexibility for different PHP and Symfony versions. After cloning, please run composer install or composer update to install the appropriate package versions and Symfony recipes for your environment.

If you want to suppress the interactive recipe prompt ("Do you want to execute this recipe?"), use Composer with the --no-interaction flag.

Configuration

First, you must register the application at https://www.discogs.com/applications/edit to get the consumer_key and consumer_secret. You can set the values as environment variables. Then they will be used by both bundles. See also calliostro/discogs-bundle.

Usage

Start the local web server of Symfony in the discogs-bundle-demo directory:

symfony serve

Or use PHP's built-in server:

php -S 127.0.0.1:8000 -t public

Open your web browser and visit the URL shown in the console output.

πŸ“‹ Available Routes

The demo provides the following routes to showcase different Discogs API features:

πŸ›£οΈ Main Routes

Route Method Description
/ GET 🏠 Home page with user authentication info and navigation
/search GET/POST πŸ” Search the Discogs database for artists, releases, labels, etc.
/artist/{id} GET 🎡 Display detailed artist information and releases
/release/{id} GET πŸ’Ώ Display detailed release information including tracklist
/label/{id} GET 🏷️ Display detailed label information and releases
/master/{id} GET 🎯 Display master release information and versions
/collection GET πŸ“€ View the authenticated user's Discogs collection
/wantlist GET πŸ’ View the authenticated user's Discogs wantlist
/profile GET πŸ‘€ View the authenticated user's complete Discogs profile
/lists GET πŸ“‹ View the authenticated user's custom lists
/list/{id} GET πŸ“ View items in a specific user list
/marketplace GET πŸ›’ Browse marketplace listings
/orders GET πŸ“¦ View and manage marketplace orders
/inventory GET πŸ“¦ View user's marketplace inventory
/random GET 🎲 Discover random releases from popular artists

🎯 Route Examples

🎡 Artist Details: /artist/8760 (Pink Floyd)
πŸ’Ώ Release Details: /release/1 (First release in the Discogs database)
🏷️ Label Details: /label/1 (Blue Note Records)
πŸ“€ Master Release: /master/5427 (Dark Side of the Moon)

πŸ” Search Examples

  • /search?q=Pink Floyd&type=artist
  • /search?q=Abbey Road&type=release
  • /search?q=Blue Note&type=label

API Features Demonstrated

Each route demonstrates different aspects of the Discogs API:

Search (/search)

πŸ“Š Database search with filtering by type
πŸ“„ Pagination support
πŸ” Multiple search types (artist, release, label, master)

Artist Details (/artist/{id})

🎀 getArtist() - Basic artist information
πŸ’½ getArtistReleases() - Artist's discography
πŸ–ΌοΈ Artist images, aliases, and band members

Release Details (/release/{id})

πŸ“€ getRelease() - Complete release information
🎡 Tracklist with track details
πŸ‘₯ Credits and contributors
🏷️ Label information and identifiers

Label Details (/label/{id})

🏒 getLabel() - Complete label information
πŸ“€ getLabelReleases() - Label's catalog
πŸ“ˆ Label statistics and history

Master Release (/master/{id})

🎯 getMaster() - Master release information
πŸ“‘ getMasterVersions() - All versions and pressings
πŸ’Ώ Format variations and differences

User Features (/collection, /wantlist, /profile)

πŸ” getOAuthIdentity() - OAuth user authentication
πŸ“ getCollectionFolders() - Collection organization
πŸ“€ getCollectionItemsByFolder() - Collection contents
πŸ’ getWantlist() - User's wanted items
πŸ‘€ getProfile() - Complete user profile with statistics

List Management (/lists, /list/{id})

πŸ“‹ getUserLists() - User's custom lists
πŸ“ getLists() - List items and details
πŸ—‚οΈ List organization and management

Marketplace (/marketplace, /orders, /inventory)

πŸ›’ getInventory() - Marketplace listings
πŸ“¦ getOrders() - Order management
πŸ’° getOrder() - Detailed order information
πŸ“Š Marketplace statistics and insights

πŸ”§ Code Examples

🎡 Basic Artist Information

#[Route('/artist/{id}', name: 'artist_detail', methods: ['GET'])]
public function artistDetail(DiscogsClient $discogs, int $id): Response
{
    $artist = $discogs->getArtist(['id' => $id]);
    $artistReleases = $discogs->getArtistReleases(['id' => $id, 'per_page' => 10]);

    return $this->render('artist_detail.html.twig', [
        'artist' => $artist,
        'releases' => $artistReleases
    ]);
}

🏷️ Label Information

#[Route('/label/{id}', name: 'label_detail', methods: ['GET'])]
public function labelDetail(DiscogsClient $discogs, int $id): Response
{
    $label = $discogs->getLabel(['id' => $id]);
    $labelReleases = $discogs->getLabelReleases(['id' => $id, 'per_page' => 10]);

    return $this->render('label_detail.html.twig', [
        'label' => $label,
        'releases' => $labelReleases
    ]);
}

πŸ“‹ User Lists Management

#[Route('/lists', name: 'user_lists', methods: ['GET'])]
public function userLists(DiscogsClient $discogs): Response
{
    $identity = $discogs->getOAuthIdentity();
    $userLists = $discogs->getUserLists([
        'username' => $identity['username'],
        'per_page' => 50
    ]);

    return $this->render('user_lists.html.twig', [
        'lists' => $userLists,
        'username' => $identity['username']
    ]);
}

πŸ›’ Marketplace Integration

#[Route('/marketplace', name: 'marketplace', methods: ['GET'])]
public function marketplace(DiscogsClient $discogs, Request $request): Response
{
    $searchQuery = $request->query->get('q', '');
    $listings = null;

    if ($searchQuery) {
        $searchResults = $discogs->search([
            'q' => $searchQuery,
            'type' => 'release',
            'per_page' => 20
        ]);
        $listings = $searchResults;
    }

    return $this->render('marketplace.html.twig', [
        'listings' => $listings,
        'searchQuery' => $searchQuery
    ]);
}

Technical Implementation

Modern PHP Features

πŸš€ PHP 8 Attributes for routing (instead of annotations)
πŸ”’ Strong typing with proper return types
⚑ Exception handling with user-friendly error messages
πŸ—οΈ Modern PHP 8.1–8.5 compatibility

UI/UX Features

🎨 Bootstrap 5 for responsive design
πŸƒ Interactive cards with hover effects
🧭 Breadcrumb navigation for better user experience
πŸ’¬ Flash messages for user feedback
πŸ“„ Pagination for large result sets

Framework Support

🎯 Symfony 6.4 (LTS) - Long-term support
⚑ Symfony 7.x β€” Latest stable features
πŸ§ͺ Symfony 8.0 (beta) - Cutting-edge features

API Integration

πŸ” OAuth authentication flow
⏱️ Rate limiting awareness
πŸ›‘οΈ Error handling for API failures
πŸš€ Caching-friendly implementation

Production Guidelines

⚠️ Important for Production Use:

  • Implement proper caching to reduce API calls
  • Respect Discogs' rate limits (60 requests per minute for authenticated requests)
  • Cache search results and static data (artists, releases, labels)
  • Use appropriate cache TTL values (e.g., 24h for releases, 1h for dynamic data)
  • Consider implementing request queuing for high-traffic applications
  • Monitor your API usage through Discogs developer dashboard

Documentation

Further documentation can be found at:
πŸ”— Discogs API v2.0 Documentation
πŸ“¦ calliostro/discogs-bundle
πŸ”§ calliostro/php-discogs-api

About

Demo project for the Discogs Symfony bundle with OAuth integration.

Topics

Resources

License

Stars

Watchers

Forks