Dapr is a portable, event-driven runtime that makes it easy for any developer to build resilient, stateless and stateful applications that run on the cloud and edge and embraces the diversity of languages and developer frameworks. Leveraging the benefits of a sidecar architecture, Dapr helps you tackle the challenges that come with building microservices and keeps your code platform agnostic.
Dapr PHP sdk does not work with latest version of laravel due dependecy issues. To solve this we needed a way to work natively with dapr using dapr's internal Api.
Dapr is portable
Dapr is language agnostic
Dapr is platform agnostic
Dapr is cloud agnostic
The above example provides two services
- Publisher Service: This service will push messages onto dapr topic
- Consumer Service: This service subscribes to the topic used by the publisher service, and route the request as per rules
-
install composer
-
run composer in publisher and consumer folders
cd consumer && composer install
cd publisher && composer install
- install docker desktop
docker compose up
-
Make a post request using postman to http://localhost:8088/api/dapr/publish
-
Sample payload
{
"orderId": "400",
"type": "cancel"
}
- Observe the log in consumer app will print the received message
-
To check dapr config for publisher send a post request to http://localhost:3500/v1.0/metadata
-
To check dapr config for consumer send a post request to http://localhost:3501/v1.0/metadata