Skip to content

Commit

Permalink
First prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed May 15, 2013
0 parents commit a037b1f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor
/composer.lock
/composer.phar
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "clue/graph-composer",
"require": {
"clue/graph": "0.5",
"jms/composer-deps-analyzer": "dev-master"
}
}
43 changes: 43 additions & 0 deletions graph-composer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use Fhaculty\Graph\GraphViz;
use Fhaculty\Graph\Graph;

require_once __DIR__ . '/vendor/autoload.php';

// directory to scan
$dir = isset($argv[1]) ? $argv[1] : __DIR__;

$analyzer = new \JMS\Composer\DependencyAnalyzer();
$dependencyGraph = $analyzer->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();

0 comments on commit a037b1f

Please sign in to comment.