xhprof 图片问题

转自  http://phpff.com/938.htmlphp

 

Xhprof在windows下点击[View Full Callgraph]调用graphviz软件时。
警告Warning: proc_open() [function.proc-open]: CreateProcess failed, error code – 0 in
并提示
failed to execute cmd " D:/graphviz-2.38/release/bin/dot -Tpng"html

位置是xhprof_lib/utils/callgraph_utils.php文件下xhprof_generate_image_by_dot函数
windows下
$cmd = " dot -T".$type;
须要替换成
$cmd = " D:/graphviz-2.38/release/bin/dot -T".$type;linux

问题就出如今这行代码
$process = proc_open($cmd, $descriptorspec, $pipes, "/tmp", array());
须要改为
$process = proc_open($cmd, $descriptorspec, $pipes);windows

或者是创建相应的tmp文件夹,由于默认是不存在tmp文件夹的。尝试在网站根目录创建tmp文件夹可是仍是保存,因而改为了在当前目录。
$process = proc_open($cmd, $descriptorspec, $pipes, "tmp", array());函数

//修改后的正确代码
function xhprof_generate_image_by_dot($dot_script, $type) {
    //echo($dot_script);
  $descriptorspec = array(
       // stdin is a pipe that the child will read from
       0 => array("pipe", "r"),
       // stdout is a pipe that the child will write to
       1 => array("pipe", "w"),
       // stderr is a pipe that the child will write to
       2 => array("pipe", "w")
       );网站

  //$cmd = " dot -T".$type; //linux下
  //1.修改graphviz目录
  $cmd = " D:/graphviz-2.38/release/bin/dot -T".$type;//windows下
  //2.tmp文件夹处理
  $process = proc_open($cmd, $descriptorspec, $pipes);
  if (is_resource($process)) {
    fwrite($pipes[0], $dot_script);
    fclose($pipes[0]);code

    $output = stream_get_contents($pipes[1]);htm

    $err = stream_get_contents($pipes[2]);
    if (!empty($err)) {
      print "failed to execute cmd: \"$cmd\". stderr: `$err'\n";
      exit;
    }ip

    fclose($pipes[2]);
    fclose($pipes[1]);
    proc_close($process);
    return $output;
  }
  print "failed to execute cmd \"$cmd\"";
  exit();
}get

相关文章
相关标签/搜索