- Notifications
You must be signed in to change notification settings - Fork53
temporalio/sdk-php
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Temporal is a distributed, scalable, durable, and highly available orchestrationengine used to execute asynchronous long-running business logic in a scalableand resilient way.
Temporal PHP SDK is the framework for authoringWorkflows andActivities using PHP language.
Table of contents:
Install the SDK using Composer:
composer require temporal/sdk
The SDK includes two main components:Clients and Workers.
The Clients component is used to start, schedule, and manage Workflows;the Workers component is used to execute Workflows and Activities.
The Clients component requires thegrpc extension,and the Workers component requiresRoadRunner.It's recommended to use both components with theprotobuf extensionin production to improve performance.
| Client | Worker | |
|---|---|---|
| RoadRunner | — | required |
| ext-grpc | required | — |
| ext-protobuf | recommended | recommended |
To download RoadRunner, you can use the following command:
./vendor/bin/rr get
If you are usingSpiral,follow theinstructions in the documentation.
If you are using the SDK without integrations, the following sections of the documentation may be helpful:
- How to run Worker Processes
- How to develop a basic Workflow
- How to connect a Temporal Client to a Temporal Service
- How to start a Workflow Execution
Note
Check outthe repository with examples of using the PHP SDK.
Warning
Since version2.11.0,feature flags were introducedthat change the behavior of the entire PHP worker.
It's recommended to disable deprecated behavior.
The PHP SDK includes a toolkit for testing Workflows.There isdocumentation anddev guide on how to test a Workflow using Activity mocking.
To ensure the determinism of a Workflow,you can also use theReplay API in tests.
Some recommendations for setting up a development environment:
TheTemporal CLI provides direct access to a Temporal Service via the terminal.You can use it to start, stop, inspect and operate on Workflows and Activities,and perform administrative tasks such as Namespace, Schedule, and Task Queue management.The Temporal CLI also includes an embedded Temporal Service suitable for use in development and CI/CD.It includes the Temporal Server, SQLite persistence, and the Temporal Web UI.
Run the following command to start the Temporal Service in development mode:
temporal server start-dev --log-level error
Experimental features:
- Add flags
--dynamic-config-value frontend.enableUpdateWorkflowExecution=true --dynamic-config-value frontend.enableUpdateWorkflowExecutionAsyncAccepted=trueto enable theWorkflow Update feature. - Add flag
--dynamic-config-value frontend.enableExecuteMultiOperation=trueto enableupdateWithStart()feature. - Add flag
--dynamic-config-value system.enableEagerWorkflowStart=trueto enable theEager Workflow Start feature.
During development, you might need to dump a variable, throw an error trace, or simply look at the call stack.Since Workflows and Activities run in RoadRunner workers, you cannot usevar_dump,print_r,echo, and other functions that output data to STDOUT.
Instead, useBuggregator along withTrap.In this case, dumps, traces, and logs will be sent via socket to your local Buggregator server,where you can view them in a convenient web interface.
Tip
Trap is a wrapper aroundsymfony/var-dumper, providing additional debugging capabilities.Moreover, Trap patches var-dumper for outputting protobuf structures, which is very handy when working with Temporal.
To run Buggregator in Docker, execute the command belowand follow theinstructions:
docker run --rm -p 8000:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 ghcr.io/buggregator/server:latest
If you are not using Docker or running PHP code outside a container, you can use Trap as a compact server:
./vendor/bin/trap --ui=8000
Now use thetrap(),tr(), ordump() functions to output data to Buggregator.Web UI will be available athttp://localhost:8000.
For advanced autocomplete while coding in PHPStorm, useMeta Storm plugin.The plugin provides better autocomplete and links Workflow and Activity when writing and debugging code.
Temporal PHP SDK is open-sourced software licensed under theMIT license.
About
Temporal PHP SDK
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.