2017 © Pedro Peláez
 

library dependency-graph

Dependency graph for PHP

image

quietfrog/dependency-graph

Dependency graph for PHP

  • Sunday, August 24, 2014
  • by alanbem
  • Repository
  • 2 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Dependency Graph

Build Status Coverage Status, (*1)

This library is a fork of https://github.com/MikeRoetgers/dependency-graph with the following changes:, (*2)

  • Renamed DependencyManager class to Graph
  • Renamed base namespace to QuietFrog
  • Hid some classes (e.g. Operation) in order to make library more generic.
  • Removed tags handling

Documentation

This is a simple implementation of a dependency graph (directed acyclic graph). Define services and dependencies between them. The graph keeps track of all dependencies and gives you an order in which services can be executed. This is especially convenient if you are working with long-running tasks and you want to identify which services may be executed in parallel., (*3)

Example

$service1 = new YourService1();
$service2 = new YourService2();
$service3 = new YourService3();
$service4 = new YourService4();

$graph = new Graph();
$graph->add($service1)->add($service2)->add($service3)->add($service4);

$graph->addDependency($service1, $service2);
$graph->addDependency($service1, $service3);
$graph->addDependency($service2, $service4);
$graph->addDependency($service3, $service4);

This definition results in the following graph:, (*4)

      1
    /  \
   2    3
    \  /
     4

Ask the graph which dependencies can be resolved. When service has been executed, mark it as resolved and ask for new available services., (*5)

$services = $graph->getUnresolvedDependencies(); // $service1
  $service1->doSomething();
$graph->markAsResolved($service1);
$services = $graph->getUnresolvedDependencies(); // $service2 and $service3
  $service3->doSomething();
$graph->markAsResolved($service3);
$services = $graph->getUnresolvedDependencies(); // $service2
  $service2->doSomething();
$graph->markAsResolved($service2);
$services = $graph->getUnresolvedDependencies(); // $service4
  $service4->doSomething();

More complex graphs are possible., (*6)

  1     2
  |    / \
  3   4   5
   \ /    |
    6     7
    |
    8

Acyclicity

The graph is acyclic, which means something like this is NOT allowed:, (*7)

$service1 = new YourService2();
$service2 = new YourService2();
$service3 = new YourService3();

$graph = new Graph();
$graph->add($service1)->add($service2)->add($service3);

$graph->addDependency($service1, $service2);
$graph->addDependency($service2, $service3);
$graph->addDependency($service3, $service1);
   1
  / \
 2 – 3

Cycles will be detected when the graph is initialized. A CircularDependencyDetectedException will be thrown., (*8)

The Versions

24/08 2014

dev-master

9999999-dev https://github.com/alanbem/dependency-graph

Dependency graph for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Mike Roetgers

24/08 2014

0.5.0

0.5.0.0 https://github.com/alanbem/dependency-graph

Dependency graph for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Mike Roetgers

28/07 2014

0.4.0

0.4.0.0 https://github.com/MikeRoetgers/dependency-graph

Dependency graph for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Mike Roetgers

10/07 2014

0.3.0

0.3.0.0 https://github.com/MikeRoetgers/dependency-graph

Dependency graph for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Mike Roetgers

09/07 2014

0.2.0

0.2.0.0 https://github.com/MikeRoetgers/dependency-graph

Dependency graph for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Mike Roetgers

08/07 2014

0.1.0

0.1.0.0 https://github.com/MikeRoetgers/dependency-graph

Dependency graph for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Mike Roetgers