diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca60d37 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor +/composer.lock +/composer.phar diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..97097bb --- /dev/null +++ b/composer.json @@ -0,0 +1,7 @@ +{ + "name": "clue/graph-composer", + "require": { + "clue/graph": "0.5", + "jms/composer-deps-analyzer": "dev-master" + } +} diff --git a/graph-composer.php b/graph-composer.php new file mode 100644 index 0000000..724bb71 --- /dev/null +++ b/graph-composer.php @@ -0,0 +1,43 @@ +analyze($dir); + +$graph = new Graph(); + +foreach ($dependencyGraph->getPackages() as $package) { + $name = $package->getName(); + $start = $graph->createVertex($name, true); + $start->setLayout(array( + 'label' => $name . ': ' . $package->getVersion(), + 'fillcolor' => '#eeeeee', + 'style' => 'filled', + 'shape' => 'box' + )); + + foreach ($package->getOutEdges() as $requires) { + $targetName = $requires->getDestPackage()->getName(); + $target = $graph->createVertex($targetName, true); + $start->createEdgeTo($target)->setLayout(array( + 'label' => $requires->getVersionConstraint(), + 'fontcolor' => '#999999', + 'fontsize' => 10 + )); + } +} + +$graph->getVertex($dependencyGraph->getRootPackage()->getName())->setLayout(array( + 'fontcolor' => 'red' +)); + +$graphviz = new GraphViz($graph); +$graphviz->setFormat('svg'); +$graphviz->display();