calliostro/discogs-bundle

Symfony bundle for the Discogs API — vinyl, music data & integration made easy

v4.0.0-beta.1 2025-09-12 10:35 UTC

This package is auto-updated.

Last update: 2025-09-12 11:03:44 UTC


README

Package Version Total Downloads License PHP Version CI Code Coverage PHPStan Level Code Style

🚀 Seamless integration of calliostro/php-discogs-api into Symfony 6.4, 7, and 8.

Use v4.0.0 for new projects with modern tooling and breaking changes. Legacy support for v3.x continues on the legacy/v3.x branch.

⚡ Requirements

  • PHP: 8.1 or higher
  • Symfony: 6.4, 7.x, or 8.x

📦 Installation

Symfony Flex (Recommended)

composer require calliostro/discogs-bundle

Without Symfony Flex

1️⃣ Install the Bundle

composer require calliostro/discogs-bundle

2️⃣ Register the Bundle

Add to config/bundles.php:

// config/bundles.php
return [
    // ...existing bundles...
    Calliostro\DiscogsBundle\CalliostroDiscogsBundle::class => ['all' => true],
];

🎸 Usage

The bundle provides a DiscogsClient service for autowiring:

// src/Controller/MusicController.php
use Discogs\DiscogsClient;

class MusicController
{
    public function getArtist(DiscogsClient $discogs): Response
    {
        $artist = $discogs->getArtist(['id' => 8760]);

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

⚙️ Configuration

Create config/packages/calliostro_discogs.yaml:

# config/packages/calliostro_discogs.yaml
calliostro_discogs:
    # Required: HTTP User-Agent header for API requests
    user_agent: 'MyApp/1.0 +https://myapp.com'

    # Recommended: Your application credentials from discogs.com/applications
    consumer_key: ~
    consumer_secret: ~

    # Rate limiting configuration
    throttle:
        enabled: true
        microseconds: 1000000  # Wait time when the rate limit is hit

    # OAuth 1.0a authentication (for user-specific data)
    oauth:
        enabled: false
        token_provider: calliostro_discogs.hwi_oauth_token_provider

🔐 Authentication

Basic Authentication (Recommended)

Register your app at Discogs Applications to get:

  • consumer_key
  • consumer_secret

This enables access to protected endpoints and higher rate limits. 🚦

OAuth 1.0a (Optional)

For user-specific data, OAuth 1.0a is supported via HWIOAuthBundle:

# config/packages/calliostro_discogs.yaml
calliostro_discogs:
    oauth:
        enabled: true
        # token_provider: calliostro_discogs.hwi_oauth_token_provider  # Default, no need to specify

🛡️ Custom Token Provider

Implement OAuthTokenProviderInterface for custom OAuth token handling:

use Calliostro\DiscogsBundle\OAuthTokenProviderInterface;

class CustomTokenProvider implements OAuthTokenProviderInterface
{
    public function getToken(): string
    {
        // Return OAuth token
    }

    public function getTokenSecret(): string
    {
        // Return OAuth token secret
    }
}

📖 Documentation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows Symfony coding standards and includes tests.

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.

🙏 Acknowledgments

⭐ Star this repo if you find it useful! It helps others discover this lightweight solution.