On the previous post, i show you how to install and use graphviz on ubuntu, let's take it to another level, this article i will show you cool tricks using graphviz, php and apache web server.
For this tutorial we are going to need php and apache web server, if you haven't got those two, you can read my other post about installing apache web server and installing php on ubuntu.
Once you have all the ingredients, we can begin the tutorial.
Using graphviz with php on ubuntu
- step 1, create a new folder on apache web server root directory
- step 2, give full permission to that new folder
- step 3, create a php file inside the folder
- step 4, copy paste code below into the php file
- step 5, open browser and run the php file
cd /var/www/html/
sudo mkdir grap
sudo chmod 777 grap
gedit index.php
<?php $input = <<<DATA digraph G { main [label="ubuntuhowto.blogspot.com"]; main -> open -> read; main -> comment; main -> subscribe; blog -> awesome; blog -> nice; nice -> good; awesome -> good; good -> job; main -> nice; } DATA; file_put_contents('input.dot', $input); exec('dot -Tpng input.dot -o graph.png'); echo ('<img src="graph.png" />'); ?>
http://localhost/grap/index.php
Pretty cool, huh?
No comments:
Post a Comment