Re: Dynamically Loading Plugins

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

 



On Sat, October 22, 2005 5:56 pm, Todd Nine wrote:
> 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.

Am I to understand that users are uploading PHP code you're going to
execute?...

Sure hope you trust them :-)

Anyway, if you can force them to use that __autoload() thingie (see
the manual) then you're all set.  Their class name matches their
filename and it just works like Magic when you make a new $whatever.

Or, the other way around, you know what to make a new of because it
matches the filename.

You need unique filenames anyway, so that keeps your class names
unique, unless somebody crams some "helper" class into their file.

May want to have a "rule" that additional classes in a file MUST have
the filename and underscore as the first part of any helper classes,
just to avoid collisions.

That would probably be the "right way"

If your version of PHP does not support __autoload, check in PECL and
PEAR and in user-contributed notes for work-arounds and
backward-compatible functions.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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