1. Go to this page and download the library: Download skrip42/node-processor 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/ */
skrip42 / node-processor example snippets
use Skrip42\NodeProcessor\Process;
use Skrip42\NodeProcessor\Node\Other\ValueNode;
use Skrip42\NodeProcessor\Node\Logical\CompareNode;
$process = new Process; //create new process;
//create all necessary nodes:
// as syntax: process->createNode($nodeClassName, ...$values) : NodeAbstract
$valNode1 = $process->createNode(ValueNode::class, 1); //you can pass start parameters to the node if NodeName, $outputNode, $inputNodeName, $inputNode)
$process->linkNode('out1', $process->getBeginNode(), 'emit', $valNode1); // you can get begin and end node
// from getBeginNode and getEndNode methods
$process->linkNode('out2', $process->getBeginNode(), 'emit', $valNode2);
$process->linkNode('out', $valNode1, 'in1', $compareNode);
$process->linkNode('out', $valNode2, 'in2', $compareNode);
$process->linkNode('more', $compareNode, 'more', $process->getEndNode()); // end node has dynamically input name
$process->linkNode('less', $compareNode, 'less', $process->getEndNode());
//You can always leave output nodes empty; can input be left blank determined by node policy
$result = $process->run(); // running process
$state = $process->getState(); // you also can get current process state for debug you script
[
'status' => currentProcessStatus,
'output' => [ .. array of end node inputs .. ]
'requests' => [ .. array of requests .. ]
]
static propery $scheme = [
'input' => [ //input declaration
'optionalInput' => [ //optional input named as 'optionalInput'
],
'' => '~in\d+~', //pattern for available input names
'property' => [
' 'outputWithoutDefaultData' => [ //output named as 'outputWithoutDefaultData'
]
],
'user_output' => [ //dynamic output declarated
], //if pattern property is null, all names available
]
$value = $this->input['inputName']['data']; //get value from 'inputName' input
$this->output['outputName']['data'] = $value; //set value to 'outputName' output (not emitted)
$this->emit('outputName');
//or you can set value and output:
$this->emit('ouputName', $sumeValue);