1. Go to this page and download the library: Download maduser/argon-workflows 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/ */
maduser / argon-workflows example snippets
$context = new MyContext(state: 'start');
$registry = new StateHandlerRegistry();
$registry->register('start', new StartHandler());
$registry->register('next', new NextHandler());
$workflow = new WorkflowDefinition(
staticTransitions: ['start' => 'next'],
signalTransitions: ['done' => 'final']
);
$workflows = new WorkflowRegistry();
$workflows->add('default', $workflow);
$runner = new WorkflowRunner(
$registry,
new TransitionResolver(),
$workflows,
maxSteps: 1000
);
$finalContext = $runner->run($context);
$observer = new MyExecutionObserver();
$runner = new WorkflowRunner(
$registry,
new TransitionResolver(),
$workflows,
null,
$observer
);
$finalContext = $runner->run($context, 'default', runId: 'job-123');
return new HandlerResult(
context: $context,
signals: ['done' => true]
);
$graph = $workflow->toGraph();
final class Agent
{
public function __construct(
private WorkflowRunner $workflowRunner,
) {}
public function run(string $agentId, string $input): LLMResponse
{
$context = new AgentContext(agentId: $agentId, input: $input);
$result = $this->workflowRunner->run($context, 'default', runId: $context->agentId);
return $result->getFinalResponse()
?? throw new RuntimeException('Agent completed but returned no response.');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.