Making a modificaton system?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Making a modificaton system?

Post by toasty2 »

What would you suggest for making my code where people can make modules/modifications for it? I'm wanting to implement a module system for my CMS that I'm writing.

So far I have:

Code: Select all

$mods = @opendir('mods') or die(getError(2));
while ($file = readdir($mods)) 
{
	if($file!='.' and $file!='..' and $file!='index.php' and strpos($file,'.php'))
	{
		include 'mods/'.$file;
	}
}
closedir($mods);
But, this method obviously has limitations and people can't really modify my code except for adding to it.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

It looks like your CMS is in transaction script style. I suggest you first look into adding hooks at key points of execution.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

What do you have? Doesn't really look like a module system. :P

Look into every known, existing open source CMS and at least 90% of them implement some kind of module system, all with their positives and negatives.

Essentially, modules range from simple extensions, like breadcrumb generators to complex mini-applications, such as realty listings module.

Depends on what kind of functionality you want ot offer in your CMS?

For a complex mini-app enhancement you want to implement your module system similar to ASP.NET using something like MVP/MVC pattern. Each module is repsonsible for generating it's own view, handling controller logic and model data. Personally I have most of these systems to limiting, dictating what they consider either good design or similar (either at GUI interface level or implementation level). Many modules are also, likely best implemented as a core part of the system, like login modules. Ick.

As you can see, things can get complicated quickly and how flexible the system is you implement really depends on your requirements.
Post Reply