PHP code example of qanna-rsa / workflow-engine

1. Go to this page and download the library: Download qanna-rsa/workflow-engine 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/ */

    

qanna-rsa / workflow-engine example snippets


Workflow::run(
    workflowId: 'send-welcome-email', 
    payload: ['email' => '[email protected]']
);

use Qanna\WorkflowEngine\Engine\Nodes\Action\LogNode;
use Qanna\WorkflowEngine\Engine\Triggers\ManualTrigger;
use Qanna\WorkflowEngine\Models\Workflow;

$workflow = Workflow::create([
    'id' => 'send-welcome-email',
    'name' => 'Send Welcome Email',
    'trigger' => ['type' => ManualTrigger::type(), 'config' => []],
    'nodes' => [[
        'id' => 'log',
        'type' => LogNode::type(),
        'config' => ['level' => 'info', 'message' => 'Welcome {{trigger.email}}'],
    ]],
    'edges' => [['from' => 'trigger', 'to' => 'log', 'branch' => 'main']],
]);

$workflow->publish('First release');

use Qanna\WorkflowEngine\Facades\Workflow;

Workflow::run('send-welcome-email', ['email' => '[email protected]']);
bash
composer vendor:publish --tag=workflowengine::config
php artisan vendor:publish --tag=workflowengine::migrations
php artisan migrate
bash
php artisan workflow:build
php artisan workflow:publish send-welcome-email