Building Temporal applications with the PHP SDK

A PHP team building on Temporal needs to know how workers, workflows and activities divide the work, and what it takes to run them safely. This page covers the build, the options and the operating load.

On this page

When a PHP team should build Temporal applications with the PHP SDK

A PHP team should build a business process as a Temporal workflow when the process spans several steps, can run for minutes, hours or days, and must finish correctly after a crash, a deploy or a failed call to a payment, ERP or messaging system. Retries, timeouts and a durable record of what happened are the features that justify the effort. If the work is a single request that finishes in seconds, or a simple queue job that can safely be re-run, a conventional queue or cron job is usually the better fit, and Temporal adds an operational dependency without removing much complexity. The PHP SDK covers three parts: clients that start workflows and send signals or queries, workers that run your workflow and activity code, and the Temporal Server, which stores event history and schedules tasks. The server is a separate system you run or buy, so the SDK does not replace it.

The team still owns most of the work. It must design workflows so their code stays deterministic across replays, decide how activities call external systems idempotently, and run worker processes under a supervisor that handles shutdown and scaling. It also owns the server: choosing between self-hosted Temporal and Temporal Cloud, the persistence and visibility stores, network exposure, and upgrades. Before committing, confirm the current PHP SDK version, the PHP versions it supports, and which features are stable or experimental in the PHP SDK documentation, since the researched facts for this page do not cover the SDK itself. Also confirm the Temporal Server version your chosen SDK release is tested against, and check whether your PHP runtime model (for example, long-running workers versus request-scoped processes) fits the worker lifecycle the SDK expects. A short proof of concept with one workflow, one activity and a forced worker restart will answer most of these questions before the design is locked.

Decide early who will run the platform. A PHP team without experience operating stateful, long-lived services should compare the internal effort of self-hosting against a managed service, because the server work recurs after launch while the workflow code is built once. The Temporal self-hosted deployment guide lists the supported ways to run the server, and the Temporal Cloud pricing page shows the published cost model for the managed option. Either way, ask any partner for a written scope that names the PHP SDK version, the server version, the workers to be built and who is responsible for upgrades and on-call alerts.

How PHP clients, workers and the Temporal Service exchange tasks

The diagram starts with a PHP client that asks the Temporal Service to start a workflow. The service records the workflow's event history in its persistence store and places workflow tasks on a task queue. A PHP worker process, which you run inside your own boundary, polls that queue, executes workflow code and activity code, and returns results to the service. Activities are the only steps that call external systems, so check which side of the boundary each dependency sits on and where the worker's credentials and network access are scoped.

Client, worker and service exchange tasks through a task queue inside a trust boundary.

Which PHP SDK deployment options fit your team

This table compares the two decisions a PHP team makes before writing code: whether to run the Temporal Service yourself or use Temporal Cloud, and where the PHP workers run. Read each row as a question about ownership, then confirm the vendor-specific details listed in the last column before committing to a design.

Decision pointWhat your team ownsWhat to confirm with the vendor
Self-hosted Temporal ServiceServer upgrades one minor version at a time, persistence database, visibility store, network exposure and access controlSupported persistence and visibility versions for your target server release, and the Helm chart version required for it
Temporal CloudNamespace design, worker connectivity, identity mapping and worker scaling; the vendor operates the serviceConnectivity options, SSO and SCIM availability on your plan, and the availability tier you need
PHP workers on virtual machinesProcess supervision, restarts, host patching, scaling by adding hosts, and network paths to the Temporal endpointWhether the PHP SDK version you chose supports the server version and the connection mode you plan to use
PHP workers on KubernetesContainer images, deployment manifests, horizontal scaling rules, graceful shutdown and secrets injectionCurrent guidance on worker autoscaling and task queue configuration for PHP workers
Other hosting for PHP workersEverything the team runs on that host, including long-running process support and outbound network accessWhether the host allows long-lived connections and background processes for workers
Authentication and access controlAuthorizer and ClaimMapper configuration for self-hosted deployments; the default allows every API requestIdentity provider options, certificate or JWT claim formats and how namespace roles map to your teams
Payload handlingCustom codecs and codec server if payloads contain regulated dataWhether Temporal Cloud supports your chosen codec approach and where keys are held
Pricing for Temporal CloudConsumption of actions and storage, and any support add-on you selectCurrent pay-as-you-go rates on the Temporal pricing page, support tiers and quoted enterprise terms

What goes in workflow code and what goes in activity code

Workflow code decides what happens next. It calls activities, starts timers, receives signals and answers queries. Temporal rebuilds workflow state by running this code again against the recorded event history, so the same code must produce the same sequence of commands every time. Confirm the exact PHP SDK names for workflow classes, activity stubs, timers, signals and queries in the official PHP SDK documentation before you write them.

  • Orchestration only: call activities through the stubs the SDK generates, and keep logic that depends on the outside world out of the workflow method.
  • Time and randomness through the SDK: use the SDK's workflow-safe clock, timers and random helpers. Calling time(), date(), rand() or random_int() directly returns a different value on replay.
  • Direct I/O breaks replay: HTTP requests, database queries, file reads and environment lookups inside workflow code return different results on each run. Move them into activities.
  • Retries declared in options: set retry policies on activity and child workflow options, so the server records each attempt and the workflow logic stays deterministic.
  • Versioning for code changes: editing workflow logic while executions are open can change the command sequence. Use the SDK's versioning mechanism, and confirm its behavior in the documentation before deploying.

Before release, check that every workflow method can replay its existing history and produce identical commands, because a mismatch leaves the workflow task failing until the code matches the history.

How to stand up a PHP worker against a Temporal service

This sequence takes a PHP team from an unconfigured connection to a worker that polls a task queue and completes a test workflow, so the team knows the client, worker and server are wired together before any business logic is added.

  1. Confirm the target server and namespace

    The platform owner confirms which Temporal Service the PHP code will reach, whether that is a self-hosted deployment in your infrastructure or Temporal Cloud, and which namespace the team will use. Confirm the frontend address, the namespace name and that the namespace is shared with the teams expected to use it. Check the server version against the upgrade guidance in the Temporal documentation, since a server running an unsupported minor line will complicate later steps. Done means the team has written down the address, namespace and version in a shared runbook and the platform owner has confirmed that network access from the PHP hosts to the frontend is allowed.

  2. Connect the PHP client with TLS and credentials

    The application engineer configures the PHP client with the server address, the namespace and the transport settings your security team approved. For a self-hosted service with mTLS enabled, load the client certificate, key and CA bundle from your secrets store rather than from the code repository. For Temporal Cloud, use the API key or certificate method your account is set up for. Confirm the exact PHP package and configuration keys against the current SDK documentation, since the client library and its option names should come from the vendor's own docs for your SDK version. Done means a small connectivity script reaches the namespace and receives a successful response without a TLS handshake error.

  3. Register one workflow and one activity

    The application engineer writes one workflow class and one activity class, then registers both with the worker on a named task queue. Keep the first pair deliberately small, for example a workflow that calls a single activity that returns a string, so that any failure points to configuration rather than business logic. Choose a task queue name that follows your naming convention and record it, because clients, workers and monitoring all depend on the same name. Done means the code compiles or loads without error and the registration list shows both types attached to the chosen task queue.

  4. Start a worker process

    The application engineer starts the worker as a long-running process on a host that can reach the Temporal frontend, using the same connection settings as the client. Run it under a process supervisor or in a container so that it restarts after a crash and stops cleanly on a shutdown signal. Watch the startup log for the task queue name and the namespace it has joined. Done means the worker log shows a successful connection and the Web UI or CLI shows a poller on the task queue, which confirms that the worker is reachable and listening for tasks.

  5. Run a test workflow from a client

    The application engineer runs a separate client script that starts the test workflow on the same namespace and task queue, passing a simple input. Record the workflow ID the client returns so the execution can be found later. Keep the client and worker in different processes, which mirrors how production traffic will reach the worker. Done means the client receives a run ID and returns the workflow result, or the start call returns without error and the execution appears in the server's list of workflow executions.

  6. Verify the execution in the Web UI or CLI

    The platform or application engineer opens the Web UI or runs the Temporal CLI against the namespace and searches for the workflow ID from the previous step. Confirm the status reads completed, that the event history shows the workflow start, the activity scheduled and completed, and the workflow completion, and that the activity result matches what the worker returned. Done means the execution is in a completed state with the expected event sequence. If the execution is stuck in running with no activity progress, check that the worker is polling the same task queue and namespace before changing any code.

Security controls PHP teams must set on the Temporal side

A PHP worker is only as protected as the Temporal Service it connects to. The controls below sit on the server side, so they apply whatever language the workflows are written in, and they decide who can reach the API, what each caller may do and who can read workflow data. Check each one before any PHP worker connects to a shared environment.

Replace the default open authorizer

If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. A PHP team that starts a cluster to test workers may leave this in place and later carry the setting into staging or production. Confirm that an Authorizer is configured in every environment and that a test request from an unauthorized caller is rejected before any PHP worker or client is pointed at the cluster.

Security docs

Encrypt internode and frontend traffic

Self-hosted Temporal supports mTLS with separate settings for internode traffic between Temporal services and frontend traffic from clients and workers. PHP workers connect to the frontend, so the frontend certificate chain must be trusted by the PHP runtime and the gRPC extension used by the SDK. Ask the platform team which certificate authority issues these certificates, how they rotate, and whether the PHP worker images carry the correct trust store.

Map identity claims to namespace roles

A ClaimMapper maps JWT or certificate claims to namespace roles, and an Authorizer plugin decides what each role may do. For PHP teams this is where a worker's service identity gets permission to poll only its own task queues in its own namespace. Design the role model with the application team before deployment, and test that a PHP worker identity cannot start or read workflows in a namespace it does not own.

Use OIDC for Web UI sign-in

Self-hosted Temporal supports OIDC single sign-on for the Web UI, so operators and developers sign in with the organization's identity provider rather than shared accounts. This matters for PHP teams because the Web UI is where they inspect workflow histories and reset or terminate executions. Confirm that access to the Web UI follows the same role model as API access and that sign-out and account removal happen in the identity provider.

Encrypt payloads with a codec

Payload encryption is handled through custom codecs and a codec server, so workflow inputs and results can be encrypted before they are stored in Temporal. PHP applications often pass customer records, tokens or account details as activity arguments, so this control protects data in workflow history. The PHP codec must be implemented, tested and deployed alongside every worker and client, and the key management process needs an owner before go-live.

Keep services off the public internet

The Temporal deployment docs say Temporal services should run on hosts not reachable from the public internet, with network access restricted to trusted internal networks. Confirm that the frontend, internode and database endpoints sit on private networks and that PHP workers reach them through approved paths. Worker credentials, secret storage and how PHP workers receive them are the responsibility of your team, so confirm those choices with your own security and platform owners.

Deployment docs

Keeping PHP workflow code safe to change

Deploying a changed workflow can break executions that are already running, because Temporal does not store a workflow's result as a snapshot of its progress. Instead, each workflow execution is recorded as an event history, and when a worker resumes that execution, the PHP workflow code is run again from the start and must make the same decisions it made the first time. If you rename an activity, reorder calls, add a step in the middle or change a timer, the replayed code can request a different command than the recorded history expects. The result is a non-determinism error on a workflow that was healthy a minute earlier. Treat every change to workflow code as a change to running executions, not only to new ones.

Protection comes from two practices. The first is versioning: you mark code paths so that executions started before a change keep following the logic they were recorded with, while new executions take the new path. The second is replay testing: you take real event histories from your environment and run them against the candidate code in CI before release, so a breaking change fails a build instead of a live execution. The mechanics, including how to collect histories and which change types need a version marker, are covered in the replay testing and versioning pages in this content group. Before relying on any versioning call in PHP, confirm the exact API in the PHP SDK documentation for the version you run, because the method names and behavior are SDK-specific.

The operational habit that makes these practices hold is keeping workers for the old code running until every execution started on it has finished. Workers pick up tasks from task queues, so a new deployment that replaces every worker at once can strand old executions if their code is no longer present. Plan to run the old and new worker builds side by side, route new work to the new build, and retire the old build only after your visibility queries show no open executions that depend on it. Ask your platform team to confirm how long your longest workflows can run, since that value sets how long old workers must stay available, and record the retirement check as a step in your release runbook.

Limits to confirm before committing to PHP

The PHP SDK sits on top of a server, persistence and visibility stack that has its own version and compatibility rules. Confirm the items below in your own environment before you commit a workflow design to PHP, because each one can change the architecture or the upgrade plan.

SDK maturity and release cadence

Ask the SDK maintainers for the current release status, the supported release history, and how quickly fixes for server-side changes reach a published version. Check the project's repository for open issues on determinism, retries and worker shutdown, since these affect how much you can rely on the SDK without patching it. Record the version you plan to pin, and decide who owns upgrading that pin when new server releases arrive. Your team should own that decision.

Server releases

Supported PHP and extension versions

Confirm which PHP versions and extensions the SDK documents as supported, and whether your current runtime image meets them. Test the exact combination you will deploy, including the gRPC and Protobuf extensions your build depends on, because a mismatch often surfaces only under load. Also confirm how your security team tracks end-of-life PHP versions, since a runtime upgrade can force a worker rebuild across every workflow team.

Worker memory and process model

PHP is normally run in short-lived request processes, while a Temporal worker is a long-running process that polls task queues and caches workflow state. Measure memory growth, garbage collection behavior and file descriptor use over a soak test that resembles your real load. Confirm how the SDK recycles workers, whether you run one process or several per host, and how a supervisor such as systemd or a container orchestrator restarts a stuck worker.

Payload size and history limits

Temporal stores workflow inputs, activity results and event history, and long histories slow replay and recovery. Ask your team to estimate payload sizes per activity from real data, and to decide where large documents go, such as object storage with a reference passed through the workflow. Confirm the history size and event count your workflows can reach, and design a continue-as-new point before the limits are hit. Use a test workflow to measure this, since the limits depend on your design.

Server and Helm chart compatibility

Choose the server version first, then confirm the Helm chart version that deploys it. Chart versions below 0.73.1 do not work with server images 1.30 and later, so a stale chart pinned in a GitOps repository can block an upgrade or break a deployment. Check the server release notes for the minor line you plan to run, and confirm that your schema upgrade runs before the server upgrade when the notes require it. Plan one minor version at a time.

Upgrade docs

Database and visibility stores

Confirm the persistence database and the visibility store against the documented support matrix before you provision them. Cassandra visibility was removed in 1.24, and Elasticsearch or OpenSearch is recommended for anything beyond a few workflow executions, so a visibility design based on SQL or a small test setup may not carry to production. Ask your database team who will operate the chosen store, how it is backed up, and how search queries from PHP operators will be governed.

Visibility docs

Questions PHP teams ask before building on Temporal

What does a Temporal PHP build cost, and what drives the effort up?

No price or effort figure is supplied for this work, so the honest answer is the drivers. Cost follows the number of workflows, how many activities call external systems, how much history and retry logic must be designed, the depth of versioning and replay testing, and how many environments the build covers. Costs split into the build itself (design, workers, activities, tests), the environment (self-hosted infrastructure you run or a Temporal Cloud subscription), and ongoing operations such as upgrades and on-call. Build costs are one-time, while infrastructure, Temporal Cloud usage and support recur. Ask any quote to itemize these components, name which environments it covers, and state the fixed scope and written acceptance criteria before work starts.

How long do a first PHP workflow and a production setup take?

Duration depends on the workflows in scope, the external systems the activities must reach, and how much of the production environment you already have. A first workflow running on a development server is usually much shorter than a production setup, which adds a persistence database, visibility storage, TLS and access control, worker deployment, monitoring and a tested upgrade path. Ask for a timeline that separates these stages, lists the prerequisites your team must complete first, and names the milestones where you review working code. Any figure in a quote should trace back to the written scope.

What must our team provide for a PHP Temporal engagement?

Three groups usually need to be involved. Your PHP runtime owners must confirm the PHP version, extensions, process manager and how workers will be started and restarted. Your platform team must provide or approve a Temporal environment, including hosts or Kubernetes namespaces, database access, network paths to the frontend, and DNS and certificates. Your security reviewers must approve the access model, the authorization setup, payload data handling and any encryption keys. Ask the quote to list each of these as client responsibilities with named owners, so delays in one group do not silently extend the schedule.

Can our in-house PHP team build Temporal workflows without a partner?

Yes, a PHP team can build Temporal workflows in-house if it has engineers who understand distributed systems, can run the server or a managed service, and will own worker operations after launch. The harder parts are rarely the first workflow. They are deterministic workflow code, versioning when workflows change while running, replay testing before deployments, worker tuning and shutdown behavior, and secure self-hosting. Assess your team against those skills, then decide which parts to keep. A partner is most useful where the first production release has a fixed deadline or where security reviews require documented controls.

Should we self-host Temporal or use Temporal Cloud for PHP workloads?

Choose self-hosted Temporal when data residency, network isolation or an air-gapped setup requires you to run the service yourself, and when your team will operate databases, visibility storage, upgrades and access control. Choose Temporal Cloud when you want Temporal Technologies to run the managed service and you can accept its hosting model and contract terms. The Temporal server is MIT licensed, so self-hosting carries no license fee for the server itself, but it moves operations cost onto your team. Compare the two options on security review requirements, operational staffing, support response needs and total cost, and ask any partner to document the decision.

How does Temporal Cloud pay-as-you-go pricing start?

Temporal Cloud pay-as-you-go pricing starts at 50 US dollars per million actions, with active storage at 0.042 US dollars per GB-hour and retained storage at 0.00105 US dollars per GB-hour, according to Temporal's pricing page. The same page lists a 99.9% SLA, or 99.99% with high availability, and SAML SSO. Support add-ons are separate: Business starts at 500 US dollars per month with a 2-hour P0 response in business hours, while Enterprise and Mission Critical are quoted by sales. Your actual bill depends on action volume, storage retained and support tier, so model those against your expected workflow load before comparing with self-hosting.

What engineering risks should we check before going live with PHP workers?

Confirm that workflow code is deterministic, because changes to workflow logic can break running executions when they replay. Check that versioning and replay tests run in CI before each deployment. Review worker shutdown, since in-flight activities must finish or retry safely during deploys. Verify that activities handle retries and idempotency for side effects such as payments or emails. Confirm that the PHP process manager restarts workers without losing task queue connections, and that payloads containing personal or regulated data are encrypted or excluded. Ask your partner to show test evidence for each item rather than only describing it.

How DeployOpen scopes and delivers a Temporal PHP build

DeployOpen plans, builds, documents and supports Temporal PHP applications inside your own infrastructure, from the first workflow design review through worker deployment and handover. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Written scope lists the workflows, activities, task queues and workers to be built for your PHP application.
  • Scope records where the Temporal Service runs, whether self-hosted or Temporal Cloud, and which persistence and visibility stores apply.
  • Scope names the security controls to confirm, including authorization, TLS, payload encryption and network exposure, before build begins.

How we build

  • Workflow code is designed for determinism, and versioning decisions are recorded before workflows that run in production are changed.
  • Worker processes are containerized and configured with task queue settings, shutdown behavior and health checks for your environment.
  • Activities are tested against mocked dependencies, and replay checks run against recorded event histories before each release.

How we hand over

  • Handover includes source code, worker deployment manifests and a runbook covering common operational tasks and errors.
  • Documentation explains how to add a workflow version, drain workers and confirm compatibility with your server version.
  • Your team receives a walkthrough of monitoring dashboards, alert rules and the upgrade path for the Temporal Server and PHP SDK.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the initial build is handed over.
  • Retainer work can cover server upgrades one minor version at a time, with the schema upgrade steps your release notes require.
  • Support scope and response expectations are agreed in writing, so your team knows who responds to a failed workflow or worker outage.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.