Skip to content

Commit f5790eb

Browse files
committed
Update README file.
1 parent aaa6af7 commit f5790eb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Blog post: [https://not-a-number.io/2018/phptree-a-fast-tree-implementation](htt
5252

5353
## Optional packages
5454

55+
* [drupol/launcher](https://github.com/drupol/launcher): To automatically open a resource using the proper application on your operating system.
5556
* [graphp/graphp](https://github.com/graphp/graph): To export a tree into a Graph.
5657

5758
## Usage
@@ -62,8 +63,10 @@ Blog post: [https://not-a-number.io/2018/phptree-a-fast-tree-implementation](htt
6263
declare(strict_types = 1);
6364

6465
use drupol\phptree\Exporter\Gv;
66+
use drupol\phptree\Exporter\GvConvert;
6567
use drupol\phptree\Node\ValueNode;
6668
use drupol\phptree\Exporter\Text;
69+
use drupol\launcher\Launcher;
6770

6871
include './vendor/autoload.php';
6972

@@ -87,6 +90,15 @@ $exporter = new Gv();
8790
$dotScript = $exporter->export($tree);
8891
file_put_contents('graph.gv', $dotScript);
8992
// Then do "dot -Tsvg graph.gv -o graph.svg" to export the script to SVG.
93+
94+
// Or use GvConvert() that does it for you.
95+
$exporter = new GvConvert();
96+
$imagePath = $exporter->setFormat('png')->export($tree);
97+
98+
// If you want to launch the image, you can use an optional package.
99+
// do: composer require drupol/launcher
100+
// then:
101+
Launcher::open($imagePath);
90102
```
91103

92104
## Code quality, tests and benchmarks

0 commit comments

Comments
 (0)