PHP code example of netlogix / dependency-resolver
1. Go to this page and download the library: Download netlogix/dependency-resolver 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/ */
netlogix / dependency-resolver example snippets
use Netlogix\DependencyResolver\TaskGraph;
$taskGraph = new TaskGraph($taskPool);
foreach ($taskGraph as $resolutionBatch) {
foreach ($resolutionBatch as $task) {
// Execute the task or do any necessary operations.
$task->resolve();
}
}
$taskGraph->resetPool();
etlogix\DependencyResolver\Task;
use Netlogix\DependencyResolver\TaskPool;
use Netlogix\DependencyResolver\TaskGraph;
$graph = new TaskGraph(
new TaskPool([
new Task('TaskA'),
new Task('TaskB', ['TaskA']),
new Task('TaskC', ['TaskA']),
new Task('TaskD', ['TaskB', 'TaskC']),
new Task('TaskE'),
])
);
$first=true;
$lines = ['stateDiagram'];
$lastTasks = [];
foreach ($graph->getIterator() as $tasks) {
foreach ($tasks as $name => $task) {
$lastTasks = array_filter($lastTasks, fn($t) => !in_array($t, $task->getDependencies()));
array_push($lines, ...$first ? [" [*] --> $name"]
: array_map(fn($t) => " $t --> $name", $task->getDependencies()));
$lastTasks[$name] = $name;
$task->resolve();
}
$first=false;
}
foreach ($lastTasks as $lastTask) {
$lines[] = " $lastTask --> [*]";
}
echo implode("\n", $lines) . "\n";
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.