Skip to content

Commit 72b2f2a

Browse files
committed
Add support for spotify-web-api-php v7 and migrate to PHP config
- Add support for `jwilsson/spotify-web-api-php` v6 and v7 - Migrate service configuration from XML to PHP format (fixes Symfony 7.4+ deprecation) - Align CI workflow with comprehensive PHP 8.2-8.5 and Symfony 6.4-8.0 test matrix
1 parent 8b13aa2 commit 72b2f2a

6 files changed

Lines changed: 87 additions & 77 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master, main ]
5+
branches:
6+
- 'main'
7+
- 'legacy/*'
8+
- 'feature/*'
9+
- 'hotfix/*'
10+
- 'release/*'
611
pull_request:
7-
branches: [ master, main ]
12+
branches:
13+
- 'main'
14+
- 'legacy/*'
15+
workflow_dispatch:
816

917
jobs:
1018
test:
@@ -14,65 +22,60 @@ jobs:
1422
fail-fast: false
1523
matrix:
1624
include:
17-
# Core PHP version testing
18-
- php: '8.1'
19-
allowed-to-fail: false
25+
# Symfony 6.4 LTS compatibility
2026
- php: '8.2'
27+
symfony-version: '6.4.*'
2128
allowed-to-fail: false
2229
- php: '8.3'
30+
symfony-version: '6.4.*'
2331
allowed-to-fail: false
2432
- php: '8.4'
33+
symfony-version: '6.4.*'
2534
allowed-to-fail: false
2635

27-
# Symfony 6.4 LTS compatibility
36+
# Symfony 7.x current versions
2837
- php: '8.2'
29-
symfony-version: '^6.4'
38+
symfony-version: '7.0.*'
3039
allowed-to-fail: false
3140
- php: '8.3'
32-
symfony-version: '^6.4'
41+
symfony-version: '7.0.*'
3342
allowed-to-fail: false
3443
- php: '8.4'
35-
symfony-version: '^6.4'
36-
allowed-to-fail: false
37-
38-
# Symfony 7.x current versions
39-
- php: '8.2'
40-
symfony-version: '^7.0'
44+
symfony-version: '7.0.*'
4145
allowed-to-fail: false
4246
- php: '8.3'
43-
symfony-version: '^7.0'
47+
symfony-version: '7.1.*'
4448
allowed-to-fail: false
45-
- php: '8.2'
46-
symfony-version: '^7.1'
49+
- php: '8.4'
50+
symfony-version: '7.1.*'
4751
allowed-to-fail: false
48-
- php: '8.3'
49-
symfony-version: '^7.1'
52+
- php: '8.4'
53+
symfony-version: '7.2.*'
5054
allowed-to-fail: false
51-
- php: '8.3'
52-
symfony-version: '^7.2'
55+
- php: '8.4'
56+
symfony-version: '7.3.*'
5357
allowed-to-fail: false
54-
- php: '8.3'
55-
symfony-version: '^7.3'
58+
- php: '8.4'
59+
symfony-version: '7.4.*'
5660
allowed-to-fail: false
5761

58-
# Future releases (November 2025) - PHP 8.5 + Symfony 8.0
59-
- php: '8.5'
60-
symfony-version: '^8.0'
61-
stability: 'dev'
62-
allowed-to-fail: true
63-
64-
# Additional future compatibility tests
62+
# Symfony 8.0 - Requires PHP 8.4+
6563
- php: '8.4'
66-
symfony-version: '^8.0'
67-
stability: 'dev'
68-
allowed-to-fail: true
64+
symfony-version: '8.0.*'
65+
allowed-to-fail: false
6966

70-
# Development stability test
71-
- php: '8.4'
72-
stability: 'dev'
73-
allowed-to-fail: true
67+
# PHP 8.5 with various Symfony versions
68+
- php: '8.5'
69+
symfony-version: '7.3.*'
70+
allowed-to-fail: false
71+
- php: '8.5'
72+
symfony-version: '7.4.*'
73+
allowed-to-fail: false
74+
- php: '8.5'
75+
symfony-version: '8.0.*'
76+
allowed-to-fail: false
7477

75-
name: "PHP ${{ matrix.php }}${{ matrix.symfony-version && format(' | Symfony {0}', matrix.symfony-version) || '' }}${{ matrix.composer-flags && format(' | {0}', matrix.composer-flags) || '' }}${{ matrix.stability && format(' | {0}', matrix.stability) || '' }}"
78+
name: "PHP ${{ matrix.php }}${{ matrix.symfony-version && format(' | Symfony {0}', matrix.symfony-version) || '' }}"
7679

7780
continue-on-error: ${{ matrix.allowed-to-fail }}
7881

@@ -99,12 +102,6 @@ jobs:
99102
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
100103
restore-keys: ${{ runner.os }}-composer-
101104

102-
- name: Configure stability
103-
if: matrix.stability
104-
run: |
105-
composer config minimum-stability ${{ matrix.stability }}
106-
composer config prefer-stable true
107-
108105
- name: Configure Symfony version
109106
if: matrix.symfony-version
110107
run: |
@@ -118,7 +115,7 @@ jobs:
118115
run: rm -f composer.lock
119116

120117
- name: Install dependencies
121-
run: composer update ${{ matrix.composer-flags }} --prefer-dist --no-interaction --no-progress
118+
run: composer update --prefer-dist --no-interaction --no-progress
122119

123120
- name: Validate composer.json
124121
run: composer validate --strict --no-check-lock

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
## ✨ Features
1111

1212
- Simple integration with Symfony 6.4, 7 & 8
13+
- Supports [jwilsson/spotify-web-api-php](https://github.com/jwilsson/spotify-web-api-php) v6 & v7
1314
- Supports Client Credentials & Authorization Code flows
1415
- Autowire Spotify API services
1516
- Customizable token provider
@@ -54,7 +55,7 @@ return [
5455
5556
## ⚙️ Configuration
5657

57-
First, you must register your application at https://developer.spotify.com/dashboard/applications to obtain the `client_id` and `client_secret`.
58+
First, you must register your application at <https://developer.spotify.com/dashboard/applications> to obtain the `client_id` and `client_secret`.
5859

5960
If you want to access user-related endpoints, the user must grant access to your application. Spotify provides OAuth 2.0 for this purpose. You need to register the `redirect_uri` in the Spotify dashboard. For the following example, you would add `https://127.0.0.1:8000/callback/` to the allowlist addresses.
6061

@@ -202,9 +203,11 @@ Implemented a missing feature? You can request it. And creating a pull request i
202203
---
203204

204205
## 🏁 Quick Start
206+
205207
1. Install the bundle with Composer
206208
2. Configure your Spotify credentials
207209
3. Autowire the service and start using the API!
208210

209211
## 💬 Support
212+
210213
For questions or help, feel free to open an issue or reach out! 😊

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"require": {
2626
"php": "^8.1",
27-
"jwilsson/spotify-web-api-php": "^6.0",
27+
"jwilsson/spotify-web-api-php": "^6.0|^7.0",
2828
"symfony/config": "^6.4|^7.0|^8.0",
2929
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
3030
"symfony/http-kernel": "^6.4|^7.0|^8.0"

src/DependencyInjection/CalliostroSpotifyWebApiExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
use Symfony\Component\Config\FileLocator;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
77
use Symfony\Component\DependencyInjection\Extension\Extension;
8-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
8+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
99
use Symfony\Component\DependencyInjection\Reference;
1010

1111
final class CalliostroSpotifyWebApiExtension extends Extension
1212
{
1313
public function load(array $configs, ContainerBuilder $container): void
1414
{
15-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
16-
$loader->load('services.xml');
15+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
16+
$loader->load('services.php');
1717

1818
$configuration = $this->getConfiguration($configs, $container);
1919
$config = $this->processConfiguration($configuration, $configs);

src/Resources/config/services.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
4+
5+
use Calliostro\SpotifyWebApiBundle\SpotifyWebApiFactory;
6+
use Calliostro\SpotifyWebApiBundle\TokenProvider;
7+
use SpotifyWebAPI\Session;
8+
use SpotifyWebAPI\SpotifyWebAPI;
9+
10+
return static function (ContainerConfigurator $configurator): void {
11+
$services = $configurator->services();
12+
13+
$services->set('calliostro_spotify_web_api.session', Session::class)
14+
->public()
15+
->args([
16+
null, // client_id - set by extension
17+
null, // client_secret - set by extension
18+
null, // redirect_uri - set by extension
19+
]);
20+
21+
$services->set('calliostro_spotify_web_api.token_provider', TokenProvider::class)
22+
->args([
23+
null, // session - set by extension
24+
]);
25+
26+
$services->set('calliostro_spotify_web_api', SpotifyWebAPI::class)
27+
->public()
28+
->factory([SpotifyWebApiFactory::class, 'factory'])
29+
->args([
30+
null, // token_provider - set by extension
31+
null, // options - set by extension
32+
]);
33+
34+
// Aliases for autowiring
35+
$services->alias(Session::class, 'calliostro_spotify_web_api.session');
36+
$services->alias(SpotifyWebAPI::class, 'calliostro_spotify_web_api');
37+
};

src/Resources/config/services.xml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)