public function export(string $type, string $filename): self
    {
        $type = escapeshellarg($type);
        $filename = escapeshellarg($filename);

        // write the dot file to a temporary file
        $tmpfile = (string) tempnam(sys_get_temp_dir(), 'gvz');
        file_put_contents($tmpfile, (string) $this);

        // escape the temp file for use as argument
        $tmpfileArg = escapeshellarg($tmpfile);

        // create the dot output
        $output = [];
        $code = 0;
        exec($this->path . "dot -T${type} -o${filename} < ${tmpfileArg} 2>&1", $output, $code);
        unlink($tmpfile);

        if ($code !== 0) {
            throw new Exception(
                'An error occurred while creating the graph; GraphViz returned: '
                . implode(PHP_EOL, $output)
            );
        }

        return $this;
    }
public function export(string $type, string $filename): self
    {
        $type = escapeshellarg($type);
        $filename = escapeshellarg($filename);

        // write the dot file to a temporary file
        $tmpfile = (string) tempnam(sys_get_temp_dir(), 'gvz');
        file_put_contents($tmpfile, (string) $this);

        // escape the temp file for use as argument
        $tmpfileArg = escapeshellarg($tmpfile);

        // create the dot output
        $output = [];
        $code = 0;
        exec($this->path . "dot -T${type} -o${filename} < ${tmpfileArg} 2>&1", $output, $code);
        unlink($tmpfile);

        if ($code !== 0) {
            throw new Exception(
                'An error occurred while creating the graph; GraphViz returned: '
                . implode(PHP_EOL, $output)
            );
        }

        return $this;
    }
public function export ( string $ type , string $ filename ) : self { $ type = escapeshellarg ( $ type ) ; $ filename = escapeshellarg ( $ filename ) ; // write the dot file to a temporary file $ tmpfile = ( string ) tempnam ( sys_get_temp_dir ( ) , 'gvz' ) ; file_put_contents ( $ tmpfile , ( string ) $ this ) ; // escape the temp file for use as argument $ tmpfileArg = escapeshellarg ( $ tmpfile ) ; // create the dot output $ output = [ ] ; $ code = 0 ; exec ( $ this -> path . "dot -T${type} -o${filename} < ${tmpfileArg} 2>&1" , $ output , $ code ) ; unlink ( $ tmpfile ) ; if ( $ code !== 0 ) { throw new Exception ( 'An error occurred while creating the graph; GraphViz returned: ' . implode ( PHP_EOL , $ output ) ) ; } return $ this ; }
Exports this graph to a generated image.

This is the only method that actually requires GraphViz.

@param string $type The type to export to; see the link above for a
list of supported types.
@param string $filename The path to write to.
@uses GraphViz/dot
@link http://www.graphviz.org/content/output-formats
@throws Exception if an error occurred in GraphViz.
Exports this graph to a generated image .