<?php 
 
    /** 
    *    $RCSfile: example.PathLocator.php,v $ 
    *    @author     $Author: Cornelius Bolten $ 
    *    @version    $Revision: 1.2 $ 
    *    @package    PathLocator 
    *     
    *    @copyright 
    *    The Initial Developer of the Original Code is Cornelius Bolten. 
    *    Portions created by Cornelius Bolten are Copyright (C) 2004 by Cornelius Bolten. 
    *    All Rights Reserved.     
    *    Usage is free for non-commercial work. see http://www.phpclasses.org/browse/package/1528.html 
    *    for more information. 
    * 
    *    @see 
    *      Latest releases are available at http://www.phpclasses.org/browse/package/1528.html.  
    *    For feedback, bug reports or enhancements please contact the author at  
    *    [email protected]. (icq: 74921090) 
    *    Thanks a lot! 
    * 
    *    @required 
    *    lib.PathLocator.php by Cornelius Bolten 
    * 
    *    here we go... 
    */ 
 
    error_reporting(E_ALL); 
 
    /** 
    * define lib-paths that we have access to 
    */ 
    $libs    =     array( 
                    "/home/www/mydomain-com/public_html/libs/", 
                    "/usr/lib/php/"                     
                ); 
     
    /** 
    * load lib.PathLocator.php 
    */ 
    include_once("lib.PathLocator.php"); 
     
    /** 
    * set-up new PathLocator-Object, with libs as only param. 
    */     
    $myPathLocator = new PathLocator($libs); 
     
    /** 
    * additionally we can add other libs via addLibraryPath() 
    */ 
    $myPathLocator->addLibraryPath("/usr/local/lib/php/"); 
 
 
    /** 
    * get some class-paths (no import!) 
    * getPath() takes a second, optional parameter, "file-type-extension" 
    * this can be "php","inc","inc.php", etc. 
    */ 
    echo "<b>Some tests showing only paths via getPath():</b><ul>"; 
    echo "<li> Mail<b>.</b>RFC822: <i>".$myPathLocator->getPath("Mail.RFC822")."</i></li>"; 
    echo "<li> Archive<b>.</b>Tar: <i>".$myPathLocator->getPath("Archive.Tar")."</i></li>"; 
    echo "<li> phplib<b>.</b>local (inc): <i>".$myPathLocator->getPath("phplib.local","inc")."</i></li>"; 
    echo "</ul>"; 
 
 
    /** 
    * try to import several classes (found in one of the PEAR paths) 
    * import() takes a second and third, optional parameter,  
    * "include-type" (include | require) AND  
    * "file-type-extension" ( php | inc | inc.php | etc. )     
    */ 
    $myPathLocator->import("XML.RPC.Server"); 
    $myPathLocator->import("PEAR.Frontend.CLI"); 
    $myPathLocator->import("PEAR.Downloader"); 
    $myPathLocator->import("Mail.mail"); 
    $myPathLocator->import("phplib.cart","include","inc"); 
 
 
    /** 
    * to see which files have been included so far 
    * we can printout included files 
    */ 
 
    /** 
    * using loop over ->includedClasses 
    */ 
    echo "<b>Show importet Files via PathLocator->includedClasses:</b><ul>"; 
    foreach($myPathLocator->includedClasses as $iClass) { 
        echo "<li>".$iClass."</li>"; 
    } 
    echo "</ul><br><br>"; 
     
    /** 
    * using global get_included_files() 
    */ 
    echo "<b>Show included Files via get_included_files():</b> (including all other include/require-calls of other scripts)<ul>"; 
    foreach(get_included_files() as $iClass) { 
        echo "<li>".$iClass."</li>"; 
    } 
    echo "</ul>" 
     
    /** 
    * that's it. pretty easy to use, i hope 
    * greetings, 
    * Cornelius 
    */ 
?>
 
 |