adachsoft / workflow-launcher-symfony-bundle
Symfony bundle for configuring and launching workflows with adachsoft/workflow-launcher.
Package info
gitlab.com/a.adach/workflow-launcher-symfony-bundle
Type:symfony-bundle
pkg:composer/adachsoft/workflow-launcher-symfony-bundle
Requires
- php: ^8.3
- adachsoft/command-executor-lib: ^2.4
- adachsoft/lease-lock: ^0.1.0
- adachsoft/workflow: ^7.1
- adachsoft/workflow-launcher: ^0.3.0
- adachsoft/workflow-launcher-contracts: ^0.2.0
- symfony/config: ^7.3
- symfony/console: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/http-kernel: ^7.3
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.5
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This bundle integrates adachsoft/workflow-launcher with Symfony applications. It configures file-backed launch envelopes and idempotency, lease-backed concurrency slots, and the workflow:launch and workflow:dispatch-resume console commands.
Installation
Install the package with Composer and register AdachSoft\WorkflowLauncherSymfonyBundle\WorkflowLauncherBundle in your Symfony application. The application must provide Psr\Clock\ClockInterface, WorkflowDefinitionRepositoryInterface, and WorkflowRunnerInterface services.
Configuration
# config/packages/workflow_launcher.yaml
workflow_launcher:
storage_dir: '%kernel.project_dir%/var/workflow-launcher'
console_path: '%kernel.project_dir%/bin/console'
slot_ttl_seconds: 21600
idempotency_ttl_seconds: 86400
workflows:
article_publishing:
max_parallel: 1
on_conflict: reject
article_correction:
max_parallel: 2
concurrency_key: 'input.slug'
storage_dir is required. The bundle creates envelopes/, idempotency/, locks/, and logs/ beneath it. The PHP executable defaults to PHP_BINARY, the console path to %kernel.project_dir%/bin/console, and the slot and idempotency TTLs to 21600 and 86400 seconds. Each workflow policy requires max_parallel (at least one), accepts an optional input path such as input.slug, and defaults on_conflict to reject.
To replace the default launch budget guard, define a service for LaunchBudgetGuardInterface or use the workflow_launcher.launch_budget_guard service alias.
Launch a workflow
php bin/console workflow:launch article_correction \
--input-json='{"slug":"stegosaurus"}' \
--requested-by=operator \
--format=json
Use --input-file instead of --input-json for larger or sensitive payloads. The two options cannot be used together.
The launch command validates the request and stores input in a private launch envelope. It starts a detached child process whose arguments contain only the generated run ID. The internal workflow:execute-launch command consumes and deletes the envelope, executes the workflow non-interactively, and releases its concurrency reservation after execution, including suspended runs.
Resuming in the background
Dispatch a decision or a due suspension timeout without keeping the calling process open:
php bin/console workflow:dispatch-resume run-123 \
--decision=approve \
--actor=operator \
--payload='{"note":"reviewed"}' \
--requested-by=operator \
--format=json
php bin/console workflow:dispatch-resume run-123 --timeout --requested-by=scheduler
Specify exactly one of --decision and --timeout. The optional decision payload must be a JSON object. Timeout requests are accepted only after the suspension deadline has arrived. The command reports the dispatch status, run ID, and any rejection reason; it exits with code 0 when started, 2 when rejected, and 1 on errors.
Applications can inject AdachSoft\WorkflowLauncherContracts\WorkflowResumeDispatcherInterface and call dispatch() with AdachSoft\WorkflowLauncherContracts\Dto\WorkflowResumeRequestDto::decision(...) or AdachSoft\WorkflowLauncherContracts\Dto\WorkflowResumeRequestDto::timeout(...). The method returns a WorkflowLaunchResultDto; a STARTED result means the resume was scheduled in a detached process, while a REJECTED result includes the reason.
Security
Workflow input may contain credentials or other secrets. It is persisted only in launch envelope files protected with mode 0600 inside the private envelope directory; it is never placed in detached process arguments. Keep the configured storage directory on a trusted filesystem with access restricted to the application user.