PHP Classes

I don't manage to make it work

Recommend this page to a friend!

      Code Graph  >  All threads  >  I don't manage to make it work  >  (Un) Subscribe thread alerts  
Subject:I don't manage to make it work
Summary:There is an error message bug this is not clear
Messages:6
Author:Laurent Girard
Date:2011-01-07 16:01:46
Update:2011-02-07 10:54:01
 

  1. I don't manage to make it work   Reply   Report abuse  
Picture of Laurent Girard Laurent Girard - 2011-01-07 16:01:46
Hello,

I tried the CodeGraph after installing the Graphviz under Windows XP. I created the "graphs" directory and executed the code. I tried to parse the parse_gen.php file and it did not work. Here is the message I got (the graphs/aa84b75d967e55d40a0e6a9045072504.jpg is not created):


expected output in graphs/aa84b75d967e55d40a0e6a9045072504.jpg
failed to generate for some reason dot file is shown below

debug
run=
output=

options=

array (
'output' => 'vertical',
'exclude_undefined' => false,
'exclude_builtins' => true,
)

params=

array (
'src_file' => 'D:\\WebSites\\WebSiteCreation\\CodeGraph\\parser_gen.php',
'opt_output' => 'Vertical',
'opt_undef' => 'YES',
'opt_builtin' => 'YES',
'submit' => 'submit',
)

  2. Re: I don't manage to make it work   Reply   Report abuse  
Picture of Colin McKinnon Colin McKinnon - 2011-01-25 23:01:18 - In reply to message 1 from Laurent Girard
Hi Laurent,

Sorry I'd not replied yet - I only found out today about the file being published!

I've never tried running this on a MSWindows machine so wouldn't know quite what to expect. There is some Unix specific code embedded within it.

The error you are seeing occurs when the script can't find the jpeg file created by the graphviz interpreter (presumably dot.exe).

Near the bottom of the file there is some code which looks like this:

$tmpfile=write_tmp_file($dotfile);
$run="/usr/bin/dot -Tjpg -o $dest $tmpfile";
$output=`$run`;

You'll definitely need to change the path to the dot interpreter.

Also in the definition of function clean_cache() it calls the Unix cli tool 'find' (the MSDOS FORFILES can provide the same functionality).

However I'm a bit confused that you did not even seem to get a valid .dot file out of the script.

I suggest you add some code in do_result to return the name and path of $tmpfile - and check if the file actually got created. It should at least create the output file even if input file was empty/unreadable.


  3. Re: I don't manage to make it work   Reply   Report abuse  
Picture of Colin McKinnon Colin McKinnon - 2011-02-04 23:04:16 - In reply to message 2 from Colin McKinnon
Since the code has been nominated for innovation award, I thought I really should clean it up a bit and make it (at least look) worthy of an award!

The revised code has a much cleaner API, and removes the need for a 'temp' directory - the output directory (which must be writeable anyway!) is used to hold the temporary file(s).

So you just need to tell it how to find the grahpvix 'dot' executable - and that can be done from the calling script - see the new readme.txt file.

HTH

C.

  4. Re: I don't manage to make it work   Reply   Report abuse  
Picture of Jan de Jong Jan de Jong - 2011-02-07 02:06:29 - In reply to message 1 from Laurent Girard
It took me about two days to find out that at least these things should be noticed to get it working on Win7:
1. adapt set_error_handler(error_logging) i.e. replace 'error_logging' to
your own;
2. the grapviz-program should be placed not in "\Program files\" because
the space prevents the start of the dot program. Make a copy somewher else e.g. c:\APPL\
3. do not use the function get_dest_file();

By the way, this is an excellent and very usefull program. I strongly recommend it. Maybe someone can extend it to include a drawing of a control graph of function. Thanx

  5. Re: I don't manage to make it work   Reply   Report abuse  
Picture of Jan de Jong Jan de Jong - 2011-02-07 02:13:48 - In reply to message 1 from Laurent Girard
Sorry, forgot this (mind the exec()-command:

$run="C:\APPL\Graphviz2.26.3\bin\\dot.exe -Tsvg -o$dest $tmpfile";
exec($run); //to generate the graph

  6. Re: I don't manage to make it work   Reply   Report abuse  
Picture of Colin McKinnon Colin McKinnon - 2011-02-07 10:54:01 - In reply to message 5 from Jan de Jong
Glad to hear you sorted it out - and thank you for detailing how you fixed it.

> Maybe someone can extend it to include a drawing of a control graph of function

Do you mean generating a flow chart for each function?