The included 'gengraph.php' script expects to read serialized data; therefore a better usage example would be :
<?php
// Add this to the page you want to track includes on
if(is_writeable('/tmp/wp.xx')) {
if(function_exists('inclued_get_data')) {
$clue = inclued_get_data();
file_put_contents('/tmp/wp.xx', serialize($clue));
}
}
?>
And to generate the human readable graph :
# First, create the dot file
$ php /path/to/inclued-src/gengraph.php -i /tmp/wp.xx -o wp.dot
# Next, create the image
$ dot -Tpng -o inclued.png wp.dot
inclued をアプリケーションに組み込む例
この例では、inclued を既存のアプリケーションに組み込んで結果を見る方法を説明します。
例1 inclued からのデータの取得
<?php
// inclued の情報を保存するファイル
$fp = fopen('/tmp/wp.json', 'w');
if ($fp) {
$clue = inclued_get_data();
if ($clue) {
fwrite($fp, json_encode($clue));
}
fclose($fp);
}
?>
データが取得できたら、それを何らかの形式で図にしてみたいと思われることでしょう。 inclued 拡張モジュールには gengraph.php という PHP ファイルが組み込まれています。 このファイルは、» graphviz ライブラリで使える dot ファイルを作成します。 しかし、これは必須ではありません。
例2 gengraph.php の使用例
この例は、inclued のデータを示す画像 inclued.png を作成します。
# まず dot ファイルを作成します $ php graphviz.php -i /tmp/wp.json -o wp.dot # そして画像を作成します $ dot -Tpng -o inclued.png wp.dot
inclued をアプリケーションに組み込む例
david at palepurple dot co dot uk
06-Mar-2009 11:23
06-Mar-2009 11:23
