tags:

views:

219

answers:

2

Hi

I just installed the Graphviz PEAR package in Cpanel and tried running the following script: (from http://pear.php.net/manual/en/package.images.image-graphviz.example.php )

[?php
require_once '/home/user_directory/php/Image/GraphViz.php';

$gv = new Image_GraphViz();
$gv->addEdge(array('wake up'        => 'visit bathroom'));
$gv->addEdge(array('visit bathroom' => 'make coffee'));
$gv->image();
?]

If I run this script I get the following error message:

Warning: fopen(/tmp/graph_8xynSO.svg) [function.fopen]: 
failed to open stream: No such file or directory in 
/home/user_directory/php/Image/GraphViz.php on line 210

I checked the permissions on the /tmp directory: they're set to 777 (though I can't see the graph_8xynSO.svg file in there). Is there anywhere else I should be looking please?

Thanks,

PHP

+1  A: 

It's quite possible the graphviz program isn't installed on your host. Do you have exec() capability, or shell access? If so, try to invoke graphviz directly via a command like:

echo "digraph G {Hello->World}" | dot -Tpng >hello.png

The Pear package won't include the graphviz program, but is just a wrapper for it. I'm not sure if cPanel does the dependency check first. If it's not your box, you may have to get the admin to install graphviz first.

If you can't get graphviz to work on your shared host, you may be able to call out to a web service to render the image. See http://bloodgate.com/graph-demo for an example.

brianegge
A: 

Thank you, I hadn't realised I needed to install graphviz itself, installing now, that's great!