Skip to content

xepozz/yii-temporal-demo

Introduction

This is demo application to show how to work with Temporal from Yii 3 application.

Installation

Install PHP dependencies:

composer i --prefer-dist

Get RoadRunner binary:

./vendor/bin/rr get-binary

Run docker containers:

docker-compose up -d

Run RoadRunner:

./rr serve -d

Usage

Now you can open http://localhost:8080 and see small description about examples:

This project is example how to use Temporal with Yii 3 application.
There are exist several examples how it works.
Examples:
If you want to see how "simple" workflow works click here.
There is usual call non-blocking action. It should work as faster as you can run usual php code.
If you want to see how "complicated" workflow works click here.
There are imitation for blocking action. Different methods calls will run with random delay: from 1 to 5 seconds per call.
If you want to see how "deferred" workflow works click here.
There are imitation for asynchronous action. You will get "job id" and you can track the status in another endpoint.
Logic for workflow will be same as "complicated" workflow.

Also, you can open Temporal admin panel the located in http://localhost:8088


To add more workflows and activities you need to configure them in config/common/temporal.php: You should add tag temporal.workflow for each new workflow and temporal.activity for each new activity.

Example:

\App\Temporal\Workflow\LongWorkflow::class => [
    'class' => \App\Temporal\Workflow\LongWorkflow::class,
    'tags' => ['temporal.workflow']
],

\App\Temporal\Activity\CommonActivity::class => [
    'class' => \App\Temporal\Activity\CommonActivity::class,
    'tags' => ['temporal.activity']
],

After that the workflows and activities will be automatically registered in src/ApplicationRunner.php

Contribution

You are welcome to add more examples, fix bugs or orthographic errors.

Useful links

Used libraries

Temporal PHP SDK RoadRunner

Temporal:

Temporal (temporal.io)

Workshops

1st part Оркестрируй это! Описываем сложные бизнес процессы на PHP - Антон Титов

2nd part Оркестрация и закон Мерфи: обрабатываем ошибки-бизнес процессов

Application (after run on local machine)

This application demo

Temporal admin panel

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages