temporal/sdk
Temporal PHP SDK for building durable, scalable workflow orchestration with Temporal. Author Workflows and Activities in PHP, run them with RoadRunner workers, and manage executions via gRPC clients. Composer-installable with optional protobuf for performance.
Strengths:
Challenges:
Workflow, Activity) may complicate future migrations if requirements change.Laravel Compatibility:
TemporalClient/Worker via ServiceProvider).dispatch(new WorkflowStartCommand())).Workflow::onCompleted(fn() => event(new WorkflowCompleted()))).Key Synergies:
beginTransaction() + Workflow::start()).Anti-Patterns:
| Risk Area | Severity | Mitigation |
|---|---|---|
| Workflow Complexity | High | Start with simple workflows (e.g., linear approval chains) before branching. |
| Temporal Server Dependency | High | Use Temporal’s local development mode early. |
| Error Handling | Medium | Implement retries with exponential backoff in activities; use Temporal’s Signal for external interruptions. |
| Performance Overhead | Medium | Benchmark workflow start times; optimize activity duration and batching. |
| Debugging | High | Leverage Temporal’s Visibility API and Laravel’s logging. |
| Team Adoption | High | Provide workshops on workflow patterns; document Laravel ↔ Temporal boundaries. |
Use Case Alignment:
Operational Model:
Laravel-Specific:
Observability:
Cost:
Core Components:
Worker::run() (can share Laravel’s app() container).WorkflowStarterService).Laravel Integration Points:
| Laravel Feature | Temporal Equivalent | Integration Strategy |
|---|---|---|
Queues (dispatch()) |
Workflow start() |
Replace dispatch(new Job) with Workflow::start(new MyWorkflow()) for long tasks. |
Jobs (HandleJobs) |
Activities | Convert Job::handle() to Activity::execute(). |
Events (event()) |
Workflow signals/queries | Emit Laravel events from workflows or vice versa. |
Commands (Artisan) |
Workflow CLI tools | Extend temporal CLI for workflow management (e.g., php artisan temporal:list). |
| Cache (Redis) | Activity inputs/outputs | Cache activity results to reduce Temporal server load. |
| Database | Workflow state (external) | Use Laravel DB for input/output data; Temporal for orchestration. |
Tech Stack Additions:
Phase 1: Proof of Concept (2–4 weeks)
Phase 2: Pilot (4–8 weeks)
Phase 3: Full Adoption (8+ weeks)
ext-curl, ext-json (standard in Laravel).ext-sodium (for advanced encryption), ext-redis (for caching).Worker class in Laravel vs. Temporal’s Worker).queue:work doesn’t conflict with temporal worker processes.Infrastructure First:
temporal worker --task-queue my-queue).Code Changes:
composer.json.TemporalClient in Laravel’s AppServiceProvider.Testing:
How can I help you explore Laravel packages today?