PHP code example of camunda8 / orchestration-cluster-api
1. Go to this page and download the library: Download camunda8/orchestration-cluster-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
camunda8 / orchestration-cluster-api example snippets
function readme_async_client(): void
{
$client = CamundaAsyncClient::fromEnvironment();
$client->deployResourcesFromFilesAsync(__DIR__ . '/resources/order-process.bpmn')
->then(static function ($result): void {
// handle the DeploymentResult once the request resolves
})
->wait();
}
function parallel_async_reads(CamundaAsyncClient $client): void
{
// Requests are issued before either promise is awaited.
$topologyPromise = $client->getTopology();
$definitionsPromise = $client->searchProcessDefinitions();
$topology = $topologyPromise->wait();
$definitions = $definitionsPromise->wait();
if ($topology instanceof TopologyResponse) {
printf("Connected to %d broker(s).\n", count($topology->getBrokers()));
}
if ($definitions instanceof ProcessDefinitionSearchQueryResult) {
printf("Found %d process definitions.\n", count($definitions->getItems()));
}
}
function readme_semantic_types(): void
{
// Identifiers are distinct value objects — you cannot accidentally pass a
// process-definition id where a tenant id is expected.
$instruction = (new ProcessInstanceCreationInstructionById())
->setProcessDefinitionId(ProcessDefinitionId::of('order-process'))
->setVariables(['orderId' => 'ORD-42']);
// Value objects validate their format on construction and stringify cleanly.
$definitionId = new ProcessDefinitionId('order-process');
echo (string) $definitionId, "\n";
}
function readme_zero_config(): void
{
// Reads CAMUNDA_REST_ADDRESS and auto-detects the auth strategy from the
// ambient environment (NONE / BASIC / OAUTH).
$client = CamundaClient::fromEnvironment();
}
function env_file_client(): CamundaClient
{
// Set CAMUNDA_LOAD_ENVFILE=true (or a path) before starting PHP. Real
// environment variables and explicit overrides still take precedence.
return CamundaClient::fromEnvironment();
}