[FM Discuss] php challenge... Plugins

Luka Frelih luka at ljudmila.org
Fri May 14 09:47:51 PDT 2010


hello!

> so instead of building this into Booki/Objavi it might be more
> appropriate to build this into the publishing script I'm working on
> now...this would mean that when you install the script on a server and
> fetch a book you could decide to also include a comment feature, anchors
> etc......these features would be added at publish (fetch) time and added
> to the fetched static content on your server.
>
> So...I want to add these features as plugins and design a simple method
> for creating new plugins to extend the functionality of books...i dont
> know what else could be added but there must be many many other ideas..
>
> so...is there anyone out there that could help me design the basic
> architecture for the plugins? i really dont know the best way to do it
> and would appreciate any help/advice...
>
>
> adam
>
>    

seems the most common architecture for php plugins is based around 
registering and hooks.

to load a plugin, you basically include its main php file. this loads 
all the code definitions - funcs, classes and runs any code outside any 
functions. this code can register hooks that plugin needs with the main 
code.

hooks are call-back points, preset in the main code, where you find the 
need for plugins to change something.
the main code calls into the registered plugins, giving them information 
and/or acces to its state and something different happens.

depending on the plugins needs and how the main program works, these 
will be in different places with different information passed. you 
should anticipate this to a point, so you can think about how it would 
be practical to implement obvious extensions (comments,...) but new 
hooks can be added later too as the need arises. i guess having a good 
idea how plugins and templates relate helps too.

this is the runtime, then you need a system to register/load/discover 
the plugins themselves. better systems also handle discovery, 
installation and updates of plugins ;)

you could try to read up on how to make plugins for drupal or 
mediawiki... get some ideas from there.

remember, kiss! and much luck...

best,
LF




More information about the Discuss mailing list