From a037b1f9c6ef52b1dd279c7a72efafe90c2b1de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 15 May 2013 12:00:10 +0200 Subject: [PATCH] First prototype --- .gitignore | 3 +++ composer.json | 7 +++++++ graph-composer.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 graph-composer.php 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();