Skip to content

Add Configuration API to the HTTP client - #152

Open
hexmode wants to merge 2 commits into
dapr:mainfrom
hexmode:add-configuration-api
Open

hexmode wants to merge 2 commits into
dapr:mainfrom
hexmode:add-configuration-api

Conversation

@hexmode

@hexmode hexmode commented Sep 21, 2026

Copy link
Copy Markdown

Description

Adds the Configuration API building block to the HTTP client:

  • DaprClient::getConfiguration() / getConfigurationAsync() — read items from a configuration store (GET /v1.0/configuration/<store>), returning array<string, ConfigurationItem>
  • DaprClient::subscribeConfiguration() / subscribeConfigurationAsync() — subscribe to changes (GET /v1.0/configuration/<store>/subscribe), returning the subscription id
  • DaprClient::unsubscribeConfiguration() / unsubscribeConfigurationAsync() — unsubscribe (GET /v1.0/configuration/<store>/<id>/unsubscribe)
  • Configuration\ConfigurationItem — value object (value / version / metadata)
  • Configuration\ConfigurationUpdate::parse() — decodes the update payload the sidecar POSTs to the app's /configuration/<store> route

Implementation notes:

  • Keys are sent as repeated key= query parameters (the query string is built manually because Dapr does not accept PHP's default key[0]= array encoding).
  • ConfigurationItem uses plain property defaults rather than constructor promotion: the deserializer instantiates it via newInstanceWithoutConstructor(), and stores such as configuration.redis omit version/metadata — with promoted defaults this fatally errors ("must not be accessed before initialization"). There is a regression test for this case.

Issue reference

Fixes #151

Checklist

  • Tests pass — full suite green (115 tests); 8 new tests in tests/ConfigurationTest.php covering request shape (URI/query/method), response mapping, sparse items, unsubscribe failure, and update parsing
  • Created/updated tests
  • Extended the documentation — readme.md ("Accessing Configuration") and a new daprdocs/content/en/php-sdk-docs/php-configuration.md page

Additionally verified end-to-end against a live sidecar (Dapr 1.18.4) with a configuration.redis store: get → subscribe → pushed update after MSET → unsubscribe.

Implement the Dapr Configuration building block over HTTP:

- DaprClient::getConfiguration() / getConfigurationAsync() — read items
  from a configuration store (GET /v1.0/configuration/<store>), returning
  a map of key => ConfigurationItem.
- DaprClient::subscribeConfiguration() / subscribeConfigurationAsync() —
  subscribe to changes (GET /v1.0/configuration/<store>/subscribe),
  returning the subscription id.
- DaprClient::unsubscribeConfiguration() / unsubscribeConfigurationAsync()
  — unsubscribe (GET /v1.0/configuration/<store>/<id>/unsubscribe).
- Configuration\ConfigurationItem value object (value/version/metadata).
- Configuration\ConfigurationUpdate::parse() to decode the update payload
  the sidecar POSTs to the app's /configuration/<store> route.

Keys are sent as repeated 'key=' query params (built manually since Dapr
does not accept PHP's key[0]= encoding). ConfigurationItem uses plain
property defaults rather than constructor promotion because the
deserializer instantiates it without the constructor and stores may omit
version/metadata.

Adds HttpConfigurationTrait, wires it into DaprHttpClient, declares the
abstract methods on DaprClient, covers it with 8 unit tests, and documents
it in the readme. Verified end-to-end against a live sidecar with the
configuration.redis store (get, subscribe, pushed update, unsubscribe).

Signed-off-by: Mark A. Hershberger <mah@nichework.com>
Signed-off-by: Mark A. Hershberger <mah@nichework.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Configuration API support to the client

1 participant