Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ name: CI

on:
push:
branches: [ master, main ]
branches:
- 'main'
- 'legacy/*'
- 'feature/*'
- 'hotfix/*'
- 'release/*'
pull_request:
branches: [ master, main ]
branches:
- 'main'
- 'legacy/*'
workflow_dispatch:

jobs:
test:
Expand All @@ -14,65 +22,63 @@ jobs:
fail-fast: false
matrix:
include:
# Core PHP version testing
# Symfony 6.4 LTS compatibility
- php: '8.1'
symfony-version: '6.4.*'
allowed-to-fail: false
- php: '8.2'
symfony-version: '6.4.*'
allowed-to-fail: false
- php: '8.3'
symfony-version: '6.4.*'
allowed-to-fail: false
- php: '8.4'
symfony-version: '6.4.*'
allowed-to-fail: false

# Symfony 6.4 LTS compatibility
# Symfony 7.x current versions
- php: '8.2'
symfony-version: '^6.4'
symfony-version: '7.0.*'
allowed-to-fail: false
- php: '8.3'
symfony-version: '^6.4'
symfony-version: '7.0.*'
allowed-to-fail: false
- php: '8.4'
symfony-version: '^6.4'
allowed-to-fail: false

# Symfony 7.x current versions
- php: '8.2'
symfony-version: '^7.0'
symfony-version: '7.0.*'
allowed-to-fail: false
- php: '8.3'
symfony-version: '^7.0'
symfony-version: '7.1.*'
allowed-to-fail: false
- php: '8.2'
symfony-version: '^7.1'
- php: '8.4'
symfony-version: '7.1.*'
allowed-to-fail: false
- php: '8.3'
symfony-version: '^7.1'
- php: '8.4'
symfony-version: '7.2.*'
allowed-to-fail: false
- php: '8.3'
symfony-version: '^7.2'
- php: '8.4'
symfony-version: '7.3.*'
allowed-to-fail: false
- php: '8.3'
symfony-version: '^7.3'
- php: '8.4'
symfony-version: '7.4.*'
allowed-to-fail: false

# Future releases (November 2025) - PHP 8.5 + Symfony 8.0
- php: '8.5'
symfony-version: '^8.0'
stability: 'dev'
allowed-to-fail: true

# Additional future compatibility tests
# Symfony 8.0 - Requires PHP 8.4+
- php: '8.4'
symfony-version: '^8.0'
stability: 'dev'
allowed-to-fail: true
symfony-version: '8.0.*'
allowed-to-fail: false

# Development stability test
- php: '8.4'
stability: 'dev'
allowed-to-fail: true
# PHP 8.5 with various Symfony versions
- php: '8.5'
symfony-version: '7.3.*'
allowed-to-fail: false
- php: '8.5'
symfony-version: '7.4.*'
allowed-to-fail: false
- php: '8.5'
symfony-version: '8.0.*'
allowed-to-fail: false

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) || '' }}"
name: "PHP ${{ matrix.php }}${{ matrix.symfony-version && format(' | Symfony {0}', matrix.symfony-version) || '' }}"

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

Expand All @@ -99,12 +105,6 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Configure stability
if: matrix.stability
run: |
composer config minimum-stability ${{ matrix.stability }}
composer config prefer-stable true

- name: Configure Symfony version
if: matrix.symfony-version
run: |
Expand All @@ -118,7 +118,7 @@ jobs:
run: rm -f composer.lock

- name: Install dependencies
run: composer update ${{ matrix.composer-flags }} --prefer-dist --no-interaction --no-progress
run: composer update --prefer-dist --no-interaction --no-progress

- name: Validate composer.json
run: composer validate --strict --no-check-lock
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## ✨ Features

- Simple integration with Symfony 6.4, 7 & 8
- Supports [jwilsson/spotify-web-api-php](https://github.com/jwilsson/spotify-web-api-php) v6 & v7
- Supports Client Credentials & Authorization Code flows
- Autowire Spotify API services
- Customizable token provider
Expand Down Expand Up @@ -54,7 +55,7 @@ return [

## ⚙️ Configuration

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

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.

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

## 🏁 Quick Start

1. Install the bundle with Composer
2. Configure your Spotify credentials
3. Autowire the service and start using the API!

## 💬 Support

For questions or help, feel free to open an issue or reach out! 😊
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"require": {
"php": "^8.1",
"jwilsson/spotify-web-api-php": "^6.0",
"jwilsson/spotify-web-api-php": "^6.0|^7.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"
Expand Down
25 changes: 16 additions & 9 deletions src/DependencyInjection/CalliostroSpotifyWebApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,36 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;

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

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

// Set arguments instead of replacing them since services.php doesn't define them
$container->getDefinition('calliostro_spotify_web_api.session')
->replaceArgument(0, $config['client_id'])
->replaceArgument(1, $config['client_secret'])
->replaceArgument(2, $config['redirect_uri']);
->setArguments([
$config['client_id'],
$config['client_secret'],
$config['redirect_uri'],
]);

$container->getDefinition('calliostro_spotify_web_api.token_provider')
->replaceArgument(0, new Reference('calliostro_spotify_web_api.session'));
->setArguments([
new Reference('calliostro_spotify_web_api.session'),
]);

$container->getDefinition('calliostro_spotify_web_api')
->replaceArgument(0, new Reference($config['token_provider']))
->replaceArgument(1, $config['options']);
->setArguments([
new Reference($config['token_provider']),
$config['options'],
]);
}
}
28 changes: 28 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Calliostro\SpotifyWebApiBundle\SpotifyWebApiFactory;
use Calliostro\SpotifyWebApiBundle\TokenProvider;
use SpotifyWebAPI\Session;
use SpotifyWebAPI\SpotifyWebAPI;

return static function (ContainerConfigurator $configurator): void {
$services = $configurator->services();

// Session service - arguments will be set by the extension
$services->set('calliostro_spotify_web_api.session', Session::class)
->public();

// Token provider - arguments will be set by the extension
$services->set('calliostro_spotify_web_api.token_provider', TokenProvider::class);

// Main Spotify Web API service - arguments will be set by the extension
$services->set('calliostro_spotify_web_api', SpotifyWebAPI::class)
->public()
->factory([SpotifyWebApiFactory::class, 'factory']);

// Aliases for autowiring
$services->alias(Session::class, 'calliostro_spotify_web_api.session');
$services->alias(SpotifyWebAPI::class, 'calliostro_spotify_web_api');
};
27 changes: 0 additions & 27 deletions src/Resources/config/services.xml

This file was deleted.