Download the PHP package calliostro/spotify-web-api-bundle without Composer
On this page you can find all versions of the php package calliostro/spotify-web-api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download calliostro/spotify-web-api-bundle
More information about calliostro/spotify-web-api-bundle
Files in calliostro/spotify-web-api-bundle
Package spotify-web-api-bundle
Short Description Symfony bundle for the Spotify Web API โ streaming, music data & integration made easy
License MIT
Homepage https://github.com/calliostro/spotify-web-api-bundle
Informations about the package spotify-web-api-bundle
Spotify Web API Bundle for Symfony
A resilient Symfony bundle integrating jwilsson/spotify-web-api-php into your Symfony application. Features automated token management for long-running CLI commands and Symfony Messenger background workers, dependency injection, autowiring, and support for Client Credentials & Authorization Code flows on PHP 8.1+ and Symfony 6.4, 7.x, and 8.x.
๐ฆ Installation
Install via Composer:
โ๏ธ Configuration
Register your application on the Spotify Developer Dashboard to obtain your client_id and client_secret.
Configure the bundle in config/packages/calliostro_spotify_web_api.yaml:
[!NOTE] If you are using the Authorization Code flow, make sure to allowlist your
redirect_uri(e.g.https://127.0.0.1:8000/callback/) in your Spotify Developer App settings.
๐ Quick Start
1. Client Credentials Flow (Machine-to-Machine)
For public data endpoints (searching tracks, getting artist info, browsing playlists), inject SpotifyClient directly into your controllers, services, or console commands:
[!TIP] Type-hinting
Calliostro\SpotifyWebApiBundle\SpotifyClientis recommended. It extendsSpotifyWebAPI\SpotifyWebAPI, ensuring full backward compatibility while providing automated token freshness checks and retry handling for long-running processes.
2. Authorization Code Flow (User Data)
To access private user data (playlists, saved tracks, top artists), inject both SpotifyClient and Session:
โก Long-Running Processes (CLI & Messenger Workers)
Spotify OAuth access tokens expire strictly after 3,600 seconds (1 hour). In standard setups, long-running CLI commands or Symfony Messenger background workers (bin/console messenger:consume) crash with a 401 Expired Token error after 60 minutes.
This bundle solves this problem automatically out of the box:
- In-Memory Caching:
TokenProvidercaches the access token in memory with an automatic freshness threshold (55 minutes). - Pre-emptive Refresh: Before any API call is sent,
SpotifyClientensures the token is still valid and refreshes it transparently if needed. - Self-Healing Retries: If Spotify returns an expired token exception,
SpotifyClientcatches it, forces a token refresh, and retries the request once before failing.
Your workers and daemon commands can run for days without interruption or manual token management.
โจ Key Features
- Resilient
SpotifyClientโ ExtendsSpotifyWebAPIwith transparent token refresh and self-healing retries. - Daemon & CLI Ready โ Runs indefinitely in Symfony Messenger workers and console commands without 60-minute token expiration crashes.
- Runtime Credential Validation โ Clear, actionable error messages pointing to your Spotify dashboard when credentials are missing.
- Seamless Autowiring โ Type-hint
SpotifyClient(recommended) orSpotifyWebAPI(deprecated alias) andSession. - Dual Flow Support โ Out-of-the-box support for both Client Credentials and Authorization Code flows.
- Client Options โ Easily toggle
auto_refresh,auto_retry, andreturn_assocvia YAML configuration. - Type Safety & IDE Support โ PHP 8.1+ types, strict types, and PHPStan Level 8 static analysis.
- Symfony Native โ Full compatibility with Symfony 6.4 LTS, 7.x, and 8.x.
๐ Requirements
- PHP
^8.1(tested on PHP 8.1โ8.6) - Symfony
^6.4 || ^7.0 || ^8.0 - jwilsson/spotify-web-api-php
^6.0 || ^7.0
๐งช Development & Testing Guide
See DEVELOPMENT.md for detailed setup instructions, test suite commands, static analysis, and contribution guidelines.
๐ค Contributing
Contributions are welcome! Please ensure that all tests pass and coding standards are maintained:
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
โ๏ธ Disclaimer
Spotify is a registered trademark of Spotify AB. This project is an independent, unofficial open-source bundle and is not affiliated with, endorsed by, or sponsored by Spotify AB.
๐ Acknowledgments
- jwilsson/spotify-web-api-php for the underlying Spotify Web API client.
- Symfony for the web framework and dependency injection container.
- Sister Symfony bundles:
calliostro/discogs-bundleโ Symfony bundle for the Discogs API.calliostro/lastfm-bundleโ Symfony bundle for the Last.fm API.calliostro/spotify-bundleโ Lightweight Symfony bundle forcalliostro/spotify-client.calliostro/musicbrainz-bundleโ Symfony bundle for the MusicBrainz API.
All versions of spotify-web-api-bundle with dependencies
jwilsson/spotify-web-api-php Version ^6.0 || ^7.0
symfony/config Version ^6.4 || ^7.0 || ^8.0
symfony/dependency-injection Version ^6.4 || ^7.0 || ^8.0
symfony/http-kernel Version ^6.4 || ^7.0 || ^8.0