Building an Extensible System
April 23, 2004 6:52 AM   Subscribe

So here's a delightfully geeky programming question for those in the know: I need to build a system, preferably in PHP, with a highly extensible plug-in system. And I don't know where to start, although I figure an OO-orientated approach might help. Any ideas?
posted by bwerdmuller to Computers & Internet (6 answers total)
 
phpNuke works in the same sort of way (extensible / plug in), so it might be worth downloading and reverse-engineering. Definitely design the thing in an OO way. I'm not sure if that's the best thing for development because I don't know PHP well enough.
phpoxsom is also modular / extensible, and may be easier to work out.
posted by seanyboy at 7:02 AM on April 23, 2004


sit down and design the system. see how best to factor out the different elements. if objects are all you know, or all that php supports, then go with objects. otherwise you can also think about more general abstract data types and higher order functions. it's not really about picking the right buzz-word - the solution should come from what works best for the problem at hand.

maybe i'm not answering the right question. are you looking for advice on how to design software? in very general terms you start with use cases (examples of how the system will be used) and try to find a description of the system (at first, just a consistent set of words) that describes how the system will work. once you have a description, you think about how that might look in code (at this point you might look at what solutions can be re-used, what language to use, etc - if you're lucky you don't have to choose your technology until here). then map your verbal description onto elements that will appear in your code. then check how this fits with your original use cases. then write the code.

there's a whole pile of variations on the above general approach. do you start by modelling the most general things, or the most specific? do you design everything up-front, or design some bits and then iterate?

despite what i said about choosing technology after looking at use cases and finding a suitable vocabulary to describe they system, people tend to choose technologies first. if you've already decided on objects, you might look at using uml, which is not a development method, but a tool to help develop oo programs. martin fowler's book "uml distilled" is a short intro to uml that's clear, easy to read, and includes a down-to-earth discussion on how to use it. "enterprise architect" is a good, reasonably priced uml environment (it provides an interface that lets you construct models and code, and check the consistency between them).

but given the way you're asking your question, it's probably better to say "try anything, but once you've got some way, take a step back and ask yourself what could be better. then look for solutions and try again." you'll start with trivial questions like "how do i make my code easier to maintain?", but eventually get to questions like "how do i abstract that process?", "how do i abstract processes in general?", "how can i describe processes?"...
posted by andrew cooke at 7:22 AM on April 23, 2004


Um... Probably need to have a better idea of what you mean by "extensible plug-in system".

Anything with easily replaceable parts will have to be properly designed with interfaces very well documented.

My knowledge in PHP is fairly limited, but from what I have noticed, objects aren't all that well implemented in PHP yet.

You may be able to keep things modular, but to be fully OO, you'll probably have to wait until PHP5 comes out
posted by PWA_BadBoy at 8:57 AM on April 23, 2004


OO in php4 is passable... but if you can wait, do so for php 5, for two reasons:

- REAL objects
- exceptions

these two things will make coding SO much easier for you.



(but, i'm drunk, and a php n33333rd, so ignore me if thou wilt.)
posted by cheaily at 9:32 AM on April 23, 2004


There seems to be some confusion about what you're asking. My assumption is that you want a strategy for a plug-in system. Going with that.........

You don't need OO for this. Just have a function that will look for available plugins at a certain context.

So let's say you want to allow plugins to (among other things) add content to your sidebar. Just have a function like GetPlugins('SideNavContext'); The app will look for plugins as it builds the page and then run the functions for those plugins as needed.

Squirrelmail does a great job of this. If you look at the plugins.php file for Squirrelmail I think you'll find it very helpful.
posted by y6y6y6 at 10:36 AM on April 23, 2004


sorry, that was a rather pointless answer. i'd go with what y6^3 says.
posted by andrew cooke at 6:24 AM on April 24, 2004


« Older Mortgage advice/opinion relevant to the UK?   |   Scandinavian travel tips? Newer »
This thread is closed to new comments.