Listing methods for all of your PHP objects for quick reference

Open Reference BookWhen managing or developing object orientated programming sites in PHP, I find that I frequently forget the names of methods that belong to classes. Even though I try to have a standard naming format – my memory still seems to fail :-(
So rather than run phpDocs over my objects continually, I knocked together this quick script to list all the methods in all my objects (I store all my objects in one directory). I call this file “_methodList.php” and keep it only on the development server. Here’s the code!
$dirpath = "/path/to/objects";
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
//Don't list subdirectories
if (!is_dir("$dirpath/$file")) {
//only grab PHP files
if ((substr($file, -3)=="php")&&($file!="_methodList.php")){
echo $file."<br/>\n";
require_once($file);
$methArr = get_class_methods(substr($file, 0, -4));
if (sizeof($methArr) > 0){
foreach ($methArr as $method){
echo "-> ".$method."<br/>\n";
}
}
echo "<br/>";
}
}
}
closedir($dh);

Thanks to Honou for the opening graphic!

Share on Facebook

Facebook comments:

Leave a Reply