-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a037b1f
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor | ||
/composer.lock | ||
/composer.phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |