calliostro / discogs-bundle
Bundle around the Discogs API client for Symfony 6.4, Symfony 7 and Symfony 8
Installs: 379
Dependents: 0
Suggesters: 3
Security: 0
Stars: 2
Watchers: 1
Forks: 9
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^8.1
- calliostro/php-discogs-api: ^2.1.0
- symfony/config: ^6.4|^7.0|^8.0
- symfony/dependency-injection: ^6.4|^7.0|^8.0
- symfony/http-kernel: ^6.4|^7.0|^8.0
- symfony/security-core: ^6.4|^7.0|^8.0
Requires (Dev)
- symfony/phpunit-bridge: ^6.4|^7.0|^8.0
Suggests
- hwi/HWIOAuthBundle: Enable OAuth support using HWIOAuthBundle
README
🚀 Easy integration of calliostro/php-discogs-api into Symfony 6.4+, 7, and 8!
📚 For more about the Discogs API, visit Discogs Developers.
⚡ 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
- API Client: See calliostro/php-discogs-api
- Discogs API: Official Documentation
- Example Application: discogs-bundle-demo
🤝 Contributing
Found a bug or missing feature? Please create an issue or submit a pull request. Contributions welcome! 💡
🙏 Credits
This bundle is based on ricbra/RicbraDiscogsBundle for Symfony 2.