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

    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:

    1. <?php
    2. use Dapr\App;
    3. $app = App::create(configure: fn(\DI\ContainerBuilder $builder) => $builder->addDefinitions(__DIR__ . '/config.php'));
    4. return ['hello' => $name];
    5. });
    6. $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!

    More Information