1. Go to this page and download the library: Download davispeixoto/workflow 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/ */
davispeixoto / workflow example snippets
use MyCLabs\Enum\Enum;
class SalesStates extends Enum
{
public const NEW = 'new';
public const DEALING = 'dealing';
public const WON = 'won';
public const LOST = 'lost';
}
use Davispeixoto\WorkflowInterface\Transition;
use Davispeixoto\WorkflowInterface\WorkflowInterface;
class SalesWorkflow extends WorkflowInterface
{
public function __construct(SalesStates $initialStatus)
{
parent::__construct($initialStatus);
// setup the transitions
$transitions = [];
$transitions[] = new Transition(
new SalesStates(SalesStates::NEW),
new SalesStates(SalesStates::DEALING)
);
$transitions[] = new Transition(
new SalesStates(SalesStates::DEALING),
new SalesStates(SalesStates::WON)
);
$transitions[] = new Transition(
new SalesStates(SalesStates::DEALING),
new SalesStates(SalesStates::LOST)
);
$this->allowedTransitions = $transitions;
// setup the finished status, if any/needed
$finished = [];
$finished[] = new SalesStates(SalesStates::WON);
$finished[] = new SalesStates(SalesStates::LOST);
$this->finishedStatus = $finished;
}
}
sh
php composer.phar update
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.