Reply to Dynamically Loading Plugins

Your name:

Reply:


Posted by Todd Nine on 10/23/05 01:56

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация