1

What I want to do is install GraphViz for PHP on Ubuntu.

I tried pear install Image_GraphViz, it installed but does not work for me.

Then I tried downloading the file from here.

File name : libgv-php5_2.32.0-1~raring_amd64.deb When I run the file it says dependency is not satisfiable libgraphviz4.

All I want to do is run the code below which is from their documentation. Unfortunately I can not find GraphViz.php to download.

<?php
require_once 'GraphViz.php';

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

How can I fix this issue? Where can I download GraphViz.php

3
  • This should probably be on Server Fault
    – Mike
    Aug 22 '13 at 5:54
  • 2
    No, this does not belong on Server Fault. Server Fault is for professional sysadmin questions. Getting PEAR modules working is way, way out of scope for SF, and is perfectly on topic on SO.
    – Charles
    Aug 22 '13 at 23:22
  • @MartinSchröder, so? It's still on-topic here.
    – Charles
    Aug 26 '13 at 15:57
2

Just install the libgv-php5 Install libgv-php5 package:

PHP5 bindings for graphviz

Graphviz is a set of graph drawing tools. See the description of the graphviz package for a full description.

This package contains the PHP5 bindings.

Using your favourite package management, e.g. apt-get, do:

sudo apt-get install libgv-php5

This should install the Graphviz for PHP in the paths used by the Ubuntu packaged version of PHP (automatically enabled in the php.ini .d directory).

You will then have to change your require_once statement to match the Ubuntu packaged version. From the manpage:

#!/usr/bin/php
<?
include('libgv-php5/gv.php');
...
?>

Also don't forget to restart your webserver if you're running PHP as a module.

2
  • Still I get Fatal error: Class 'Image_GraphViz' not found in /var/www/
    – Techie
    Aug 27 '13 at 3:30
  • @Dasun How about replacing your require_once with require_once 'libgv-php5/gv.php'; ?
    – gertvdijk
    Aug 27 '13 at 7:58
3

You should install the graphviz package via apt:

$ sudo apt-get install graphviz

Then Image_Graphviz is able to use the dot command that is provided by graphviz.

4
  • Where can I find the GraphViz.php file to be included?
    – Techie
    Aug 22 '13 at 8:22
  • 4
    @Dasun if you correctly ran the pear command, then the file will be in your include path already.
    – Charles
    Aug 22 '13 at 23:22
  • Still I get Fatal error: Class 'Image_GraphViz' not found in /var/www/
    – Techie
    Aug 27 '13 at 3:30
  • Follow the PEAR setup instructions: pear.php.net/manual/en/installation.checking.php
    – cweiske
    Aug 27 '13 at 4:04
0

GraphViz.php is the file contained in the Image_GraphViz package. It would likely be in a folder named Image_GraphViz. Therefore include the full path in your require_once statement. The file defines the Image_GraphViz class that provides an interface to the actual GraphViz system (installed separately).

0

At first reinstall pear:

wget http://pear.php.net/go-pear.phar    
php go-pear.phar

After that install graphviz via pear:

sudo pear install Image_GraphViz

That's all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.