1. Go to this page and download the library: Download systream/state-machine 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/ */
systream / state-machine example snippets
$stateMachine = new StateMachine(new \Systream\EventDispatcher());
$inStock = new StateMachine\State('In stock');
$ordered = new StateMachine\State('Ordered');
$shippingInProcess = new StateMachine\State('Shipping in process');
$deliveredToClient = new StateMachine\State('Order is at client');
$stateMachine->addTransition(
new GenericTransition('Order'), $inStock, $ordered
);
$stateMachine->addTransition(
new GenericTransition('Cancel order'), $ordered, $inStock
);
$stateMachine->addTransition(
new GenericTransition('Shipping'), $ordered, $shippingInProcess
);
$stateMachine->addTransition(
new GenericTransition('Handover to client'), $shippingInProcess, $deliveredToClient
);
$product = new DummyStateObject();
$product->setState($inStock);
$stateMachine->can($product, $ordered); // will return true
$stateMachine->can($product, $deliveredToClient); // will return false
$product = new DummyStateObject();
$product->setState($inStock);
$stateMachine->process($product, $ordered);
$product = new DummyStateObject();
$product->setState($inStock);
$stateMachine->process($product, $deliveredToClient);
$states = $stateMachine->getStates();
$product = new DummyStateObject();
$states = $stateMachine->getNextStates($product);
$doFileGenerator = new StateMachine\DotFileGenerator();
$image = $doFileGenerator->getImage($stateMachine);
file_put_contents('my_flow_chart.png', $image);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.