4

I work for the small ISP. We need to draw network topology in our project for network management. I usually have this data:

"cisco" | => "d-link" | => "d-link"

and so on...

So. Using PHP and jQuery how can i draw simple but nice topology picture? Thanks in advance! Appreciate your support.

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
skater_nex
  • 453
  • 1
  • 5
  • 11

1 Answers1

5

In PHP, you could call out to Graphviz to make the images. There's probably a PHP wrapper for Graphviz already written out there, but it's pretty easy to call it yourself.

For example, this input file (in example.dot):

digraph example {
    dlink1 [label="d-link"];
    dlink2 [label="d-link"];
    cisco -> dlink1;
    cisco -> dlink2;
}

Can be converted into an image:

$ dot -Tpng -o example.png example.dot

Here's the result:

Result from Graphviz

icktoofay
  • 126,289
  • 21
  • 250
  • 231
  • 2
    and you can make output in svg format + each of node and link can be shown as a link – k102 Feb 09 '12 at 06:25
  • very interesting. need some "on the fly" method to use it without command line... – skater_nex Feb 09 '12 at 06:41
  • 1
    @skater_nex: I was suggesting you have PHP run that command whenever it needed to generate a graph. Alternatively, you could try to find some extension that lets Graphviz run within the PHP process. – icktoofay Feb 09 '12 at 06:48
  • I use pear Image_GraphViz to generate graph within PHP. http://pear.php.net/package/Image_GraphViz @skater_nex – Sunry Aug 25 '13 at 04:15