1. Go to this page and download the library: Download chatflowphp/automata 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/ */
chatflowphp / automata example snippets
use Automata\Contracts\AutomatonInterface;
use Automata\Contracts\ContextInterface;
use Automata\Contracts\InputInterface;
use Automata\Core\Context\ArrayContext;
use Automata\Core\CycleRequest;
use Automata\Core\CycleResponse;
use Automata\Core\Orchestrator;
$context = new ArrayContext();
$automaton = new class implements AutomatonInterface {
public function getId(): string
{
return 'demo';
}
public function onEnter(ContextInterface $context): void
{
$context->set('status', 'idle');
}
public function process(CycleRequest $request): CycleResponse
{
$request->getContext()->set('status', 'processed');
return CycleResponse::none();
}
public function onLeave(ContextInterface $context): void
{
}
};
$orchestrator = new Orchestrator($context);
$orchestrator->registerAutomaton($automaton);
$orchestrator->activate('demo');
$orchestrator->tick(new class implements InputInterface {});
bash
php examples/simple-workflow/run.php
bash
php examples/traffic-light/run.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.