Dapr PHP SDK
Dapr offers an SDK to help with the development of PHP applications. Using it, you can create PHP clients, servers, and virtual actors with Dapr.
Optional Prerequisites
- xdebug – for debugging
Initialize your project
In a directory where you want to create your service, run and answer the questions. Install dapr/php-sdk
and any other dependencies you may wish to use.
Create your service
Create index.php
and put the following contents:
<?php
use Dapr\App;
$app = App::create(configure: fn(\DI\ContainerBuilder $builder) => $builder->addDefinitions(__DIR__ . '/config.php'));
return ['hello' => $name];
});
$app->start();
Initialize dapr with dapr init
and then start the project with .
Congratulations, you’ve created your first Dapr service! I’m excited to see what you’ll do with it!