From 04efcecf23696d08085f3141112db4b24cd2fcdd Mon Sep 17 00:00:00 2001 From: Samantha Coyle Date: Wed, 18 Nov 2026 18:00:44 -0600 Subject: [PATCH 1/2] docs: refresh README with title, install step and community links Signed-off-by: Samantha Coyle --- readme.md | 99 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/readme.md b/readme.md index be42dec..c17ed71 100644 --- a/readme.md +++ b/readme.md @@ -1,51 +1,26 @@ -# Using this library +# Dapr SDK for PHP [![PHP Composer](https://github.com/dapr/php-sdk/actions/workflows/php.yml/badge.svg)](https://github.com/dapr/php-sdk/actions/workflows/php.yml) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/dapr/php-sdk/blob/main/LICENSE) +[![Discord](https://img.shields.io/discord/778680217417809931?label=Discord&style=flat&logo=discord)](https://bit.ly/dapr-discord) -This library is licensed with the MIT license. +The Dapr SDK for PHP lets PHP applications use [Dapr](https://dapr.io) for state management, actors, pub/sub and +secrets, and ships a PSR-15 middleware that serves the actor and subscription routes for you. -Add the library to your `composer.json`: +- Documentation: [docs.dapr.io/developing-applications/sdks/php](https://docs.dapr.io/developing-applications/sdks/php/) +- Community: [Dapr Discord](https://bit.ly/dapr-discord) +- Other Dapr SDKs: [docs.dapr.io/developing-applications/sdks](https://docs.dapr.io/developing-applications/sdks/) -> composer require dapr/php-sdk +# Installation -Some basic documentation is below, more documentation can be -found [in the docs](https://docs.dapr.io/developing-applications/sdks/php/); +This library requires PHP 8.4 or later. Add it to your project with Composer: -# Migrating to 1.2 - -In preparation for gRPC support in this SDK, there's now a new DaprClient in `\Dapr\Client\DaprClient`. Please update -your code to use the new client. - -There shouldn't be many changes to your code to upgrade to 1.2+ from a prior version. Namely, there are some -deprecations: - -## Deprecations - -The following have been deprecated and will be removed in 1.4+. - -### \Dapr\SecretManager has been deprecated - -Simply use the new client instead. - -### \Dapr\Client has been deprecated - -Simply use the new client: `\Dapr\Client\DaprClient`. - -### \Dapr\PubSub\Publish has been deprecated - -Simply instantiate `\Dapr\PubSub\Topic` directly or use the new client directly. - -## Fallbacks and Upgrades - -### \Dapr\State\StateManager - -This class has been upgraded to use the new client. It shouldn't require any changes to your code, however, the old -behavior can be utilized with `\Dapr\State\StateManagerOld`. - -### \Dapr\State\TransactionalState +```sh +composer require dapr/php-sdk +``` -This class has been upgrade to use the new client. It shouldn't require any changes to your code, however, the old -behavior can be utilized with `\Dapr\State\TransactionalStateOld`. +Some basic documentation is below; more documentation can be +found [in the docs](https://docs.dapr.io/developing-applications/sdks/php/). # Creating a Dapr Client @@ -87,7 +62,7 @@ There are several ways to access state. You can access state directly via the cl ```php ['value' => $value, 'etag' => $etag] = $client->getStateAndEtag(storeName: 'statestore', key: 'key', asType: SomeClass::class, consistency: \Dapr\consistency\EventualLastWrite::instance()); -$value = $client->getState(storeName: 'statestore', key: 'key', asType: 'string',consistency: \Dapr\consistency\StrongFirstWrite::instance()) +$value = $client->getState(storeName: 'statestore', key: 'key', asType: 'string',consistency: \Dapr\consistency\StrongFirstWrite::instance()); ``` ## Abstract via Object @@ -150,7 +125,7 @@ objects or commit transactions directly. ```php $transaction = [ \Dapr\Client\StateTransactionRequest::upsert(key: 'key', value: $client->serializer->as_json($new_value)), - \Dapr\Client\StateTransactionRequest::delete(key: 'key'); + \Dapr\Client\StateTransactionRequest::delete(key: 'key'), ]; $client->executeStateTransaction(storeName: 'statestore', operations: $transaction); ``` @@ -248,7 +223,7 @@ use Dapr\Actors\ActorProxy; $app->get('/increment/{actorId}[/{amount:\d+}]', function(string $actorId, ActorProxy $actorProxy, int $amount = 1) { $counter = $actorProxy->get(ICounter::class, $actorId); $counter->increment($amount); - $counter->create_reminder('increment', new \Dapr\Actors\Reminder('increment', new DateInterval('PT10M'), data: 10 )); + $counter->create_reminder(new \Dapr\Actors\Reminder('increment', new DateInterval('PT10M'), data: 10 )); }); $app->start(); ``` @@ -335,9 +310,45 @@ $app->start(); $client = \Dapr\Client\DaprClient::clientBuilder() ->withDeserializationConfig($configuration) ->withSerializationConfig($configuration) - ->build() + ->build(); ``` +# Migrating to 1.2 + +In preparation for gRPC support in this SDK, there's now a new DaprClient in `\Dapr\Client\DaprClient`. Please update +your code to use the new client. + +There shouldn't be many changes to your code to upgrade to 1.2+ from a prior version. Namely, there are some +deprecations: + +## Deprecations + +The following have been deprecated and will be removed in 1.4+. + +### \Dapr\SecretManager has been deprecated + +Simply use the new client instead. + +### \Dapr\Client has been deprecated + +Simply use the new client: `\Dapr\Client\DaprClient`. + +### \Dapr\PubSub\Publish has been deprecated + +Simply instantiate `\Dapr\PubSub\Topic` directly or use the new client directly. + +## Fallbacks and Upgrades + +### \Dapr\State\StateManager + +This class has been upgraded to use the new client. It shouldn't require any changes to your code, however, the old +behavior can be utilized with `\Dapr\State\StateManagerOld`. + +### \Dapr\State\TransactionalState + +This class has been upgrade to use the new client. It shouldn't require any changes to your code, however, the old +behavior can be utilized with `\Dapr\State\TransactionalStateOld`. + # Development ## Tests From dd304ff933419600170c70453bcc5d5fe6ad29b7 Mon Sep 17 00:00:00 2001 From: Samantha Coyle Date: Wed, 18 Nov 2026 20:12:14 -0600 Subject: [PATCH 2/2] docs: fix README middleware sample to match the App API Signed-off-by: Samantha Coyle --- readme.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index c17ed71..fb9d2b9 100644 --- a/readme.md +++ b/readme.md @@ -34,10 +34,12 @@ The `App` object also implements a PSR-15 compatible middleware which implements for you. ```php -$app = \Dapr\App::create(configure: [ +$app = \Dapr\App::create(configure: fn(\DI\ContainerBuilder $builder) => $builder->addDefinitions([ // custom configuration -]); -use_middleware($app); +])); + +// add $app to your PSR-15 framework's middleware stack, which then calls: +// $app->process($request, $handler); ``` # Accessing Secrets