From 83abf707b6af01b3e49f4095f0c40d5af3a2ddfb Mon Sep 17 00:00:00 2001 From: Florent Huck Date: Mon, 4 May 2026 17:01:59 +0200 Subject: [PATCH 1/3] README.mustache: add release procedure --- templates/php/README.mustache | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/templates/php/README.mustache b/templates/php/README.mustache index 3addf328..c08bd1fd 100644 --- a/templates/php/README.mustache +++ b/templates/php/README.mustache @@ -92,6 +92,26 @@ Contributions are welcome!
Please open a [pull request](https://github.com/{{composerPackageName}}/compare) or an [issue](https://github.com/{{composerPackageName}}/issues/new) for any improvements, bug fixes, or new features. +## Publishing +To generate a new version of the Upsun SDK PHP and automatically publish it on https://packagist.org + +1. update your local +```bash +git fetch +git checkout main +git pull +``` +2. check existing tags on https://github.com/upsun/upsun-sdk-php/tags +3. create a new tag from your local +```bash +git tag v +git push --tag +``` +4. Go on release page: https://github.com/upsun/upsun-sdk-php/releases +5. create a new release based on the previously created tag (Do not forget to autogenerate description in the form) +6. check publishing action status: https://github.com/upsun/upsun-sdk-php/actions +7. check new release version on https://packagist.org/packages/upsun/upsun-sdk-php + ## Tests To run the tests, use: From 74c4aa0bc33574681d3c85687e24ecc715d0dd25 Mon Sep 17 00:00:00 2001 From: Florent Huck Date: Mon, 1 Jun 2026 12:55:22 +0200 Subject: [PATCH 2/3] feat: make HTTP client PSR-18 agnostic and remove hard Symfony dependency --- composer.json | 4 +++- src/UpsunClient.php | 9 ++++----- templates/php/libraries/psr-18/composer.mustache | 4 +++- tests/UpsunClientTest.php | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 7fc4eafb..2231134a 100644 --- a/composer.json +++ b/composer.json @@ -36,13 +36,15 @@ "php-http/client-common": "^2.4", "php-http/discovery": "^1.14", "php-http/httplug": "^2.2", - "symfony/http-client": "^6.3|^7", "psr/http-client-implementation": "^1.0", "psr/http-factory": "^1.0", "psr/http-factory-implementation": "^1.0", "psr/http-message": "^1.0", "nyholm/psr7": "^1.8" }, + "suggest": { + "symfony/http-client": "Install a PSR-18 HTTP client implementation if your application does not already provide one" + }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.89", "guzzlehttp/guzzle": "^7.0", diff --git a/src/UpsunClient.php b/src/UpsunClient.php index 31b1e34f..7960e65e 100644 --- a/src/UpsunClient.php +++ b/src/UpsunClient.php @@ -2,9 +2,9 @@ namespace Upsun; +use Http\Discovery\Psr18ClientDiscovery; use Http\Discovery\Psr17FactoryDiscovery; use Psr\Http\Client\ClientInterface; -use Symfony\Component\HttpClient\Psr18Client; use Upsun\Api\AddOnsApi; use Upsun\Api\ApiConfiguration; use Upsun\Api\ApiTokensApi; @@ -145,18 +145,17 @@ class UpsunClient public WorkersTask $workers; - public function __construct(protected UpsunConfig $upsunConfig) + public function __construct(protected UpsunConfig $upsunConfig, ?ClientInterface $apiClient = null) { $this->apiConfig = ApiConfiguration::getDefaultConfiguration() ->setHost(host: $this->upsunConfig->base_url); - // Symfony HTTP client compatible PSR-18 - $this->apiClient = new Psr18Client(); + $this->apiClient = $apiClient ?? Psr18ClientDiscovery::find(); $requestFactory = Psr17FactoryDiscovery::findRequestFactory(); $this->auth = new OAuthProvider( - httpClient: $this->apiClient, // Symfony PSR-18 client + httpClient: $this->apiClient, requestFactory: $requestFactory, tokenEndpoint: $this->upsunConfig->auth_url . "/" . $this->upsunConfig->token_endpoint, clientId: $this->upsunConfig->clientId, diff --git a/templates/php/libraries/psr-18/composer.mustache b/templates/php/libraries/psr-18/composer.mustache index dc191af0..8e4a5a61 100644 --- a/templates/php/libraries/psr-18/composer.mustache +++ b/templates/php/libraries/psr-18/composer.mustache @@ -27,13 +27,15 @@ "php-http/client-common": "^2.4", "php-http/discovery": "^1.14", "php-http/httplug": "^2.2", - "symfony/http-client": "^6.3|^7", "psr/http-client-implementation": "^1.0", "psr/http-factory": "^1.0", "psr/http-factory-implementation": "^1.0", "psr/http-message": "^1.0", "nyholm/psr7": "^1.8" }, + "suggest": { + "symfony/http-client": "Install a PSR-18 HTTP client implementation if your application does not already provide one" + }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.89", "guzzlehttp/guzzle": "^7.0", diff --git a/tests/UpsunClientTest.php b/tests/UpsunClientTest.php index 90143791..783c9d1f 100644 --- a/tests/UpsunClientTest.php +++ b/tests/UpsunClientTest.php @@ -65,6 +65,22 @@ public function testConstructorInitializesHttpClient() $this->assertInstanceOf(ClientInterface::class, $this->upsunClient->apiClient); } + public function testConstructorUsesInjectedHttpClient() + { + $customConfig = new UpsunConfig( + base_url: 'https://api.upsun.com', + auth_url: 'https://auth.upsun.com', + apiToken: 'test-api-token', + token_endpoint: 'oauth2/token', + clientId: 'test-client-id' + ); + + $apiClient = $this->createMock(ClientInterface::class); + $upsunClient = new UpsunClient($customConfig, $apiClient); + + $this->assertSame($apiClient, $upsunClient->apiClient); + } + public function testConstructorInitializesOAuthProvider() { $this->assertInstanceOf(OAuthProvider::class, $this->upsunClient->auth); From 492f8fd8dc9e6105f804d7855ed1af2a6dda81ac Mon Sep 17 00:00:00 2001 From: Florent Huck Date: Mon, 1 Jun 2026 13:08:43 +0200 Subject: [PATCH 3/3] fix all --- README.md | 6 +++--- src/UpsunClient.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2f780638..4274e461 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,9 @@ git tag v git push --tag ``` 4. Go on release page: https://github.com/upsun/upsun-sdk-php/releases -7. create a new release based on the previously created tag (Do not forget to autogenerate description in the form) -8. check publishing action status: https://github.com/upsun/upsun-sdk-php/actions -9. check new release version on https://packagist.org/packages/upsun/upsun-sdk-php +5. create a new release based on the previously created tag (Do not forget to autogenerate description in the form) +6. check publishing action status: https://github.com/upsun/upsun-sdk-php/actions +7. check new release version on https://packagist.org/packages/upsun/upsun-sdk-php ## Tests diff --git a/src/UpsunClient.php b/src/UpsunClient.php index 7960e65e..9c7af1c0 100644 --- a/src/UpsunClient.php +++ b/src/UpsunClient.php @@ -2,8 +2,8 @@ namespace Upsun; -use Http\Discovery\Psr18ClientDiscovery; use Http\Discovery\Psr17FactoryDiscovery; +use Http\Discovery\Psr18ClientDiscovery; use Psr\Http\Client\ClientInterface; use Upsun\Api\AddOnsApi; use Upsun\Api\ApiConfiguration;