Dynamically Loading Plugins

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.
I have need to dynamically load some classes. I have created an
abstract class that defines a function. Note that I'm using PHP 4 so
abstract is not enforced. 3rd party plugins will then implement this
interface. Users will upload their plugins via a web interface. After
I save the php class file to the directory ./plugins, I will need to
load it later. Basically I need to do something like.


$dir = dir("plugins");

while($entry=$dir->read() ) {

    //skip non class php files.
    if(!eregi(".+\.class\.php$", $entry )) {
        continue;
    }//end if

    //dynamically load class and call it

    //require class
    require_once("plugins/".$entry);


    //get the class name from the entry

    $classname = ??? ?;

    $plugin = new $classname();

    //result array
    $results = $plugin->getObjects();

    //do other stuff

}//end while

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux