- How do I install Durable Workflow in a Laravel 11+ project?
- Run `composer require durable-workflow/workflow` to install the package. Ensure your project uses PHP 8.2+ and Laravel 11+. The package auto-registers its service provider, but verify your `.env` includes a supported queue driver (e.g., `QUEUE_CONNECTION=database` or `redis`).
- Can I use Durable Workflow with Laravel Horizon for monitoring?
- Yes, workflows appear in Horizon as 'Workflow Jobs' with custom metrics like `activities_completed` and `retries_attempted`. No additional configuration is needed beyond installing the package and running Horizon’s queue worker.
- What Laravel versions does Durable Workflow support?
- Durable Workflow requires Laravel 11+ (PHP 8.2+) due to dependency updates. Older Laravel versions (e.g., 10.x) are unsupported, though you can check the GitHub issues for potential downgrade paths or community forks.
- How do I define a workflow with activities in PHP?
- Use the `Workflow` class to define steps and `Activity` classes for tasks. For example, create a `PaymentWorkflow` with `ChargeActivity` and `NotifyActivity`, then dispatch it via `dispatch(new WorkflowJob($workflowDefinition))`. The package provides a declarative syntax for sequencing.
- Does Durable Workflow support parallel execution of activities?
- Yes, workflows can execute activities in parallel using the `--concurrency` flag with the `workflow:execute` Artisan command. For example, `php artisan workflow:execute --concurrency=5` runs up to 5 activities concurrently. Adjust based on your queue driver’s capacity.
- How do I handle retries for failed activities in a workflow?
- Retries are built into the package. Configure retry logic via the `retry` method in your `Activity` class (e.g., `retry(3, 100)` for 3 attempts with 100ms delay). Failed activities trigger Laravel’s queue retry mechanism, and you can customize error handling via `WorkflowObserver`.
- Can I integrate Durable Workflow with non-PHP services (e.g., Go, Java)?
- Yes, use the `WorkerProtocolClient` with gRPC to call activities implemented in other languages. The package handles serialization/deserialization of complex payloads. Ensure your services expose gRPC endpoints and your PHP environment has the `grpc/grpc` extension installed.
- What storage options are supported for workflow persistence?
- Durable Workflow supports PostgreSQL, MySQL, and SQLite (with limitations). PostgreSQL/MySQL require `jsonb` for activity context, which may need schema migrations. SQLite users should avoid alpha features like the LAMBDA queue driver, as it lacks full support.
- How do I monitor workflow progress in real-time?
- Workflow events implement `ShouldBroadcast`, so you can push updates to clients via Laravel Echo/Pusher. Subscribe to events like `WorkflowStarted` or `ActivityCompleted` in your frontend. The package also logs workflow lifecycle events to Laravel’s log system.
- Are there alternatives to Durable Workflow for Laravel workflows?
- Alternatives include `spatie/laravel-workflow` (simpler, less feature-rich) and `laravel-activity` for basic task orchestration. For advanced use cases like sagas or microservice orchestration, Durable Workflow offers superior parallelism, retries, and cross-language support. Evaluate based on your need for durability and complexity.