Skip to content

Commit a037b1f

Browse files
committed
First prototype
0 parents  commit a037b1f

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor
2+
/composer.lock
3+
/composer.phar

composer.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "clue/graph-composer",
3+
"require": {
4+
"clue/graph": "0.5",
5+
"jms/composer-deps-analyzer": "dev-master"
6+
}
7+
}

graph-composer.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
use Fhaculty\Graph\GraphViz;
4+
use Fhaculty\Graph\Graph;
5+
6+
require_once __DIR__ . '/vendor/autoload.php';
7+
8+
// directory to scan
9+
$dir = isset($argv[1]) ? $argv[1] : __DIR__;
10+
11+
$analyzer = new \JMS\Composer\DependencyAnalyzer();
12+
$dependencyGraph = $analyzer->analyze($dir);
13+
14+
$graph = new Graph();
15+
16+
foreach ($dependencyGraph->getPackages() as $package) {
17+
$name = $package->getName();
18+
$start = $graph->createVertex($name, true);
19+
$start->setLayout(array(
20+
'label' => $name . ': ' . $package->getVersion(),
21+
'fillcolor' => '#eeeeee',
22+
'style' => 'filled',
23+
'shape' => 'box'
24+
));
25+
26+
foreach ($package->getOutEdges() as $requires) {
27+
$targetName = $requires->getDestPackage()->getName();
28+
$target = $graph->createVertex($targetName, true);
29+
$start->createEdgeTo($target)->setLayout(array(
30+
'label' => $requires->getVersionConstraint(),
31+
'fontcolor' => '#999999',
32+
'fontsize' => 10
33+
));
34+
}
35+
}
36+
37+
$graph->getVertex($dependencyGraph->getRootPackage()->getName())->setLayout(array(
38+
'fontcolor' => 'red'
39+
));
40+
41+
$graphviz = new GraphViz($graph);
42+
$graphviz->setFormat('svg');
43+
$graphviz->display();

0 commit comments

Comments
 (0)