PHP code example of phelixjuma / guiflow

1. Go to this page and download the library: Download phelixjuma/guiflow 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/ */

    

phelixjuma / guiflow example snippets



$data = [
    'customer_name' => 'Naivas',
    'delivery_location' => 'Kilimani',
    'items' => [
        ['name' => 'Capon Chicken', 'quantity' => 2,'uom' => 'KGS', 'unit_price' => 100]
    ],
    "delivery_date" => "2023-09-04"
];

$config = json_decode('[{
    "rule": "Split orders for different brands",
    "skip": "0",
    "description": "",
    "stage": "split_orders",
    "dependencies": [],
    "condition": {
      "path": "items.*.matched_value.PrincipalCode",
      "operator": "exists"
    },
    "actions": [
      {
        "stage": "split_items",
        "description": "",
        "dependencies": [],
        "skip":"0",
        "action": "function",
        "path": "",
        "function": "split",
        "args": {
          "split_path": "items",
          "criteria_path": "items.*.matched_value.PrincipalCode"
        }
      }
    ]
  }]');
  
class userDefinedFunctionsClass {
    // class that defines all user defined functions outside the package ecosystem. 
}

$udfObj = new userDefinedFunctionsClass();

$workflow = new Workflow($config, $udfObj);
$workflow->run($data, true); // set second parameter to true for parallel execution        

print_r($data); // this will show the modified data