Skip to content

Commit fb4d5ec

Browse files
authored
Merge pull request #540: Update readme
2 parents 5cf33ab + 340d39e commit fb4d5ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+189
-131
lines changed

README.md

Lines changed: 141 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,165 @@
11
# Temporal PHP SDK
22

3-
[![CI Status](https://github.com/temporalio/sdk-php/actions/workflows/testing.yml/badge.svg)](https://github.com/temporalio/php-sdk/actions)
4-
[![Stable Release](https://poser.pugx.org/temporal/sdk/version)](https://packagist.org/packages/temporal/sdk)
5-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftemporalio%2Fsdk-php.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Ftemporalio%2Fsdk-php?ref=badge_shield)
6-
7-
## Introduction
8-
93
Temporal is a distributed, scalable, durable, and highly available orchestration
104
engine used to execute asynchronous long-running business logic in a scalable
115
and resilient way.
126

13-
"Temporal PHP SDK" is the framework for authoring workflows and activities using
14-
PHP language.
7+
Temporal PHP SDK is the framework for authoring [Workflows](https://docs.temporal.io/workflows) and [Activities](https://docs.temporal.io/activities) using PHP language.
8+
9+
**Table of contents:**
10+
- [Get starting](#get-starting)
11+
- [Installation](#installation)
12+
- [Usage](#usage)
13+
- [Testing](#testing)
14+
- [Dev environment](#dev-environment)
15+
- [Temporal CLI](#temporal-cli)
16+
- [Buggregator](#buggregator)
17+
- [Resources](#resources)
18+
- [License](#license)
1519

16-
## Installation
20+
## Get starting
1721

18-
SDK is available as composer package and can be installed using the
19-
following command in a root of your project:
22+
### Installation
23+
24+
Install the SDK using Composer:
2025

2126
```bash
2227
composer require temporal/sdk
2328
```
2429

25-
Make sure to install [RoadRunner](https://github.com/spiral/roadrunner) to enable workflow and activity consumption in your PHP workers.
30+
[![PHP](https://img.shields.io/packagist/php-v/temporal/sdk.svg?style=flat-square&logo=php)](https://packagist.org/packages/temporal/sdk)
31+
[![Stable Release](https://poser.pugx.org/temporal/sdk/version?style=flat-square)](https://packagist.org/packages/temporal/sdk)
32+
[![Total DLoads](https://img.shields.io/packagist/dt/temporal/sdk.svg?style=flat-square)](https://packagist.org/packages/temporal/sdk/stats)
33+
[![License](https://img.shields.io/packagist/l/temporal/sdk.svg?style=flat-square)](LICENSE.md)
34+
35+
The SDK includes two main components: [Clients](https://docs.temporal.io/develop/php/temporal-clients) and Workers.
36+
The Clients component is used to start, schedule, and manage Workflows;
37+
the Workers component is used to execute Workflows and Activities.
38+
39+
The Clients component requires the [`grpc`](https://pecl.php.net/package/grpc) extension,
40+
and the Workers component requires [RoadRunner](https://roadrunner.dev).
41+
It's recommended to use both components with the [`protobuf`](https://pecl.php.net/package/protobuf) extension
42+
in production to improve performance.
43+
44+
| | Client | Worker |
45+
|--------------|-------------|-------------|
46+
| RoadRunner || required |
47+
| ext-grpc | required ||
48+
| ext-protobuf | recommended | recommended |
49+
50+
To download RoadRunner, you can use the following command:
51+
52+
```bash
53+
./vendor/bin/rr get
54+
```
2655

27-
## Usage
56+
### Usage
2857

29-
See [examples](https://github.com/temporalio/samples-php) to get started.
58+
If you are using [Spiral](https://github.com/spiral/framework),
59+
follow the [instructions in the documentation](https://spiral.dev/docs/temporal-configuration/).
60+
61+
If you are using the SDK without integrations, the following sections of the documentation may be helpful:
62+
- [How to run Worker Processes](https://docs.temporal.io/develop/php/core-application#run-a-dev-worker)
63+
- [How to develop a basic Workflow](https://docs.temporal.io/develop/php/core-application#develop-workflows)
64+
- [How to connect a Temporal Client to a Temporal Service](https://docs.temporal.io/develop/php/temporal-clients#connect-to-a-dev-cluster)
65+
- [How to start a Workflow Execution](https://docs.temporal.io/develop/php/temporal-clients#start-workflow-execution)
66+
67+
> [!NOTE]
68+
> Check out [the repository with examples](https://github.com/temporalio/samples-php) of using the PHP SDK.
69+
70+
> [!WARNING]
71+
> Since version [`2.11.0`](https://github.com/temporalio/sdk-php/releases/tag/v2.11.0),
72+
> [feature flags](https://github.com/temporalio/sdk-php/blob/master/src/Worker/FeatureFlags.php) were introduced
73+
> that change the behavior of the entire PHP worker.
74+
> It's recommended to disable deprecated behavior.
3075
3176
## Testing
3277

33-
See [testing manual](testing/Readme.md) to get started.
78+
The PHP SDK includes a toolkit for testing Workflows.
79+
There is [documentation](https://docs.temporal.io/develop/php/testing-suite) and [dev guide](testing/Readme.md) on how to test a Workflow using Activity mocking.
80+
81+
To ensure the determinism of a Workflow,
82+
you can also use the [Replay API in tests](https://docs.temporal.io/develop/php/testing-suite#replay).
83+
84+
## Dev environment
85+
86+
Some recommendations for setting up a development environment:
87+
88+
### Temporal CLI
89+
90+
The [Temporal CLI](https://docs.temporal.io/cli) provides direct access to a Temporal Service via the terminal.
91+
You can use it to start, stop, inspect and operate on Workflows and Activities,
92+
and perform administrative tasks such as Namespace, Schedule, and Task Queue management.
93+
The Temporal CLI also includes an embedded Temporal Service suitable for use in development and CI/CD.
94+
It includes the Temporal Server, SQLite persistence, and the Temporal Web UI.
95+
96+
Run the following command to start the Temporal Service in development mode:
97+
98+
```bash
99+
temporal server start-dev --log-level error
100+
```
101+
102+
Experimental features:
103+
- Add flags `--dynamic-config-value frontend.enableUpdateWorkflowExecution=true --dynamic-config-value frontend.enableUpdateWorkflowExecutionAsyncAccepted=true`
104+
to enable the [Workflow Update feature](https://docs.temporal.io/encyclopedia/workflow-message-passing#sending-updates).
105+
- Add flag `--dynamic-config-value frontend.enableExecuteMultiOperation=true` to enable [`updateWithStart()` feature](https://php.temporal.io/classes/Temporal-Client-WorkflowClient.html#method_updateWithStart).
106+
- Add flag `--dynamic-config-value system.enableEagerWorkflowStart=true` to enable the [Eager Workflow Start feature](https://docs.temporal.io/develop/advanced-start-options#eager-start).
107+
108+
### Buggregator
109+
110+
During development, you might need to dump a variable, throw an error trace, or simply look at the call stack.
111+
Since Workflows and Activities run in RoadRunner workers, you cannot use `var_dump`,
112+
`print_r`, `echo`, and other functions that output data to STDOUT.
113+
114+
Instead, use [Buggregator](https://buggregator.dev) along with [Trap](https://github.com/buggregator/trap).
115+
In this case, dumps, traces, and logs will be sent via socket to your local Buggregator server,
116+
where you can view them in a convenient web interface.
117+
118+
> [!TIP]
119+
> Trap is a wrapper around `symfony/var-dumper`, providing additional debugging capabilities.
120+
> Moreover, Trap patches var-dumper for outputting protobuf structures, which is very handy when working with Temporal.
121+
122+
To run Buggregator in Docker, execute the command below
123+
and follow the [instructions](https://docs.buggregator.dev/config/var-dumper.html#configuration):
124+
125+
```bash
126+
docker run --rm -p 8000:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 ghcr.io/buggregator/server:latest
127+
```
128+
129+
If you are not using Docker or running PHP code outside a container, you can use Trap as a compact server:
130+
131+
```bash
132+
./vendor/bin/trap --ui=8000
133+
```
134+
135+
Now use the `trap()`, `tr()`, or `dump()` functions to output data to Buggregator.
136+
Web UI will be available at `http://localhost:8000`.
137+
138+
## Resources
139+
140+
Read the docs
141+
[![Temporal Documentation](https://img.shields.io/static/v1?style=flat-square&label=&message=Dcumentation&logo=Temporal&color=7744ee)](https://docs.temporal.io/)
142+
[![PHP SDK Documentation](https://img.shields.io/static/v1?style=flat-square&label=PHP+SDK&message=Dev+guide&logo=Temporal&color=7766ee)](https://docs.temporal.io/develop/php)
143+
[![PHP SDK API](https://img.shields.io/static/v1?style=flat-square&label=PHP+SDK&message=API&logo=PHP&color=447723&logoColor=aa88ff)](https://php.temporal.io/)
144+
145+
Ask a question
146+
[![Github issues](https://img.shields.io/static/v1?style=flat-square&label=&message=Issues&logo=Github&color=202020)](https://github.com/temporalio/sdk-php/issues)
147+
[![Slack](https://img.shields.io/static/v1?style=flat-square&label=&message=Slack&logo=Slack&color=cc4444)](https://t.mp/slack)
148+
[![Forum](https://img.shields.io/static/v1?style=flat-square&label=&message=Forum&logo=Discourse&color=4477ee)](https://community.temporal.io/tag/php-sdk)
149+
[![Discord](https://img.shields.io/static/v1?style=flat-square&label=&message=Discord&logo=Discord&color=333333)](https://discord.gg/FwmDtGQe55)
150+
151+
Stay tuned
152+
[![Read Blog](https://img.shields.io/static/v1?style=flat-square&label=&message=Read+the+Blog&logo=Temporal&color=312f2b)](https://temporal.io/blog)
153+
[![Temporal YT Channel](https://img.shields.io/static/v1?style=flat-square&label=&message=Watch+on+Youtube&logo=youtube&color=b9002a)](https://www.youtube.com/temporalio)
154+
[![X](https://img.shields.io/badge/-Follow-black?style=flat-square&logo=X)](https://x.com/temporalio)
155+
156+
Additionally
157+
[![Temporal community](https://img.shields.io/static/v1?style=flat-square&label=&message=Community&color=ff6644&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5NyIgaGVpZ2h0PSI3NiI+PHBhdGggZD0iTTQyLjc0MDMgMTYuNTYyMkM0My43MjA0IDE3LjI3NzUgNDcuNjY3MyAyMC40Mjk3IDQ4LjY0NzQgMjEuMTk3OUM0OS42Mjc1IDIwLjM3NjcgNTMuNTc0NCAxNy4yNzc1IDU0LjU1NDUgMTYuNTYyMkM3NC41Mjc0IDEuNjIyMjggOTAuNTAwNSAtMi44MDE0MiA5NC45NTA3IDEuNjQ4NzhDOTkuNDAwOSA2LjA5ODk4IDk1LjAwMzcgMjIuMDQ1NSA4MC4wMzcyIDQyLjA0NUM3OS4zMjIgNDMuMDI1MSA3Ni4xNjk4IDQ2Ljk3MiA3NS40MDE2IDQ3Ljk1MjFDNzEuNjY2NiA1Mi40ODE3IDY3LjQ4MTMgNTcuMTk2OCA2Mi42ODY3IDYxLjk5MTRDNTcuODkyMSA2Ni43ODYgNTMuMjMgNzAuOTcxMyA0OC42NDc0IDc0LjcwNjNDNDQuMTE3NyA3MC45NzEzIDM5LjQwMjYgNjYuNzg2IDM0LjYwOCA2MS45OTE0QzI5LjgxMzUgNTcuMTk2OCAyNS42MjgyIDUyLjUzNDcgMjEuODkzMiA0Ny45NTIxQzIxLjA3MiA0Ni45NzIgMTcuOTcyOCA0My4wMjUxIDE3LjI1NzYgNDIuMDQ1QzIuMzE3NiAyMi4wNzIgLTIuMTA2MTEgNi4wOTg5OSAyLjM0NDA5IDEuNjQ4NzlDNi43OTQyOSAtMi44MDE0MSAyMi43NjczIDEuNjIyMjcgNDIuNzQwMyAxNi41NjIyWiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==)](https://temporal.io/community)
158+
[![Awesome Temporal](https://img.shields.io/static/v1?style=flat-square&label=&message=Awesome+Temporal&logo=Awesome-Lists&color=4b4567)](https://github.com/temporalio/awesome-temporal)
34159

35-
## Documentation
36-
The documentation on how to use the Temporal PHP SDK and client is [here](https://docs.temporal.io/).
37160

38161
## License
39-
MIT License, please see [LICENSE](LICENSE.md) for details.
40162

163+
Temporal PHP SDK is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
41164

42165
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftemporalio%2Fsdk-php.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Ftemporalio%2Fsdk-php?ref=badge_large)

src/Activity/ActivityContextInterface.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ interface ActivityContextInterface
2121
* Returns information about current activity execution.
2222
*
2323
* @see Activity::getInfo()
24-
*
2524
*/
2625
public function getInfo(): ActivityInfo;
2726

2827
/**
2928
* Returns activity execution input arguments.
3029
*
3130
* @see Activity::getInput()
32-
*
3331
*/
3432
public function getInput(): ValuesInterface;
3533

3634
/**
3735
* Check if the heartbeat's first argument has been passed.
3836
*
3937
* @see Activity::hasHeartbeatDetails()
40-
*
4138
*/
4239
public function hasHeartbeatDetails(): bool;
4340

@@ -55,7 +52,6 @@ public function getHeartbeatDetails($type = null);
5552
* Marks the activity as incomplete for asynchronous completion.
5653
*
5754
* @see Activity::doNotCompleteOnReturn()
58-
*
5955
*/
6056
public function doNotCompleteOnReturn(): void;
6157

src/Activity/ActivityInfo.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ final class ActivityInfo
3737
* A correlation token that can be used to complete the activity through `complete` method.
3838
*
3939
* @see ActivityCompletionClientInterface::complete()
40-
*
4140
*/
4241
#[Marshal(name: 'TaskToken')]
4342
public string $taskToken;
@@ -56,14 +55,12 @@ final class ActivityInfo
5655
* activity through `complete` method.
5756
*
5857
* @see ActivityCompletionClientInterface::complete()
59-
*
6058
*/
6159
#[Marshal(name: 'ActivityID')]
6260
public string $id;
6361

6462
/**
6563
* Type (name) of the activity.
66-
*
6764
*/
6865
#[Marshal(name: 'ActivityType', type: ObjectType::class, of: ActivityType::class)]
6966
public ActivityType $type;
@@ -73,36 +70,31 @@ final class ActivityInfo
7370

7471
/**
7572
* Maximum time between heartbeats. 0 means no heartbeat needed.
76-
*
7773
*/
7874
#[Marshal(name: 'HeartbeatTimeout', type: DateIntervalType::class)]
7975
public \DateInterval $heartbeatTimeout;
8076

8177
/**
8278
* Time of activity scheduled by a workflow
83-
*
8479
*/
8580
#[Marshal(name: 'ScheduledTime', type: DateTimeType::class)]
8681
public \DateTimeInterface $scheduledTime;
8782

8883
/**
8984
* Time of activity start
90-
*
9185
*/
9286
#[Marshal(name: 'StartedTime', type: DateTimeType::class)]
9387
public \DateTimeInterface $startedTime;
9488

9589
/**
9690
* Time of activity timeout
97-
*
9891
*/
9992
#[Marshal(name: 'Deadline', type: DateTimeType::class)]
10093
public \DateTimeInterface $deadline;
10194

10295
/**
10396
* Attempt starts from 1, and increased by 1 for every retry if
10497
* retry policy is specified.
105-
*
10698
*/
10799
#[Marshal(name: 'Attempt')]
108100
public int $attempt = 1;

src/Client/Common/RpcRetryOptions.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public function withCongestionInitialInterval($interval): self
7373
*
7474
* @param null|float $coefficient Maximum amount of jitter.
7575
* Default will be used if set to {@see null}.
76-
*
7776
*/
7877
#[Pure]
7978
public function withMaximumJitterCoefficient(?float $coefficient): self

src/Client/GRPC/BaseClient.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ public function close(): void
165165

166166
/**
167167
* @param null|Pipeline<GrpcClientInterceptor, object> $pipeline
168-
*
169168
*/
170169
final public function withInterceptorPipeline(?Pipeline $pipeline): static
171170
{

src/Client/Update/UpdateHandle.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function getId(): string
5656

5757
/**
5858
* Check there is a cached accepted result or failure for this update request.
59-
*
6059
*/
6160
public function hasResult(): bool
6261
{

0 commit comments

Comments
 (0)