1Answer
  • 14
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

build a plugin system with php

I'm working on a custom CMS for my own use and was thinking about implementing a plugin system so I could extend the code a little easier. I'm having trouble conceptualizing the architecture and layout though.

I know I could go through a few open source programs that implement similar features but this is really just academic at this point so I really don't want to spend too much time digging through foreign code.

Does anyone have any good ideas of how to proceed? If someone could outline how some of the more popular programs do it that'd be perfect.

      • 2
    • Can you provide your own insights for this question? It's been a while since you asked this question and I'm interested to know what are the most important aspects you learned from your own experience writing custom php CMSs.
      • 1
    • @AdrianMoisa Tho I'm not the OP, I think it worth to comment that writing your CMS is a pretty simple and straightforward thing - if you just try to do it, step by step. Reading books or tutorials on that can be more confusing than helping. (Reading good docs like php.net, however, is always helpful). Another thing I learned: use OOP (perhaps with Composer autoloader). Classes are like boxes where you HAVE to sort all the stuff. Again, reading on OOP can make your brain damaged, so just do it in natural way, not like those Java-freaks say. Not much to add: simple PDO, sessions, JS editor...
  1. Define the functionality you want the plugins to plug into (ie, what will they do and over what)
  2. Define a class hierarchy on which plugins fit, like, all article mangling plugins should inherit from ArticleMangler
  3. Define a physical location for plugins, like /plugins
  4. Import all plugins present in the location
  5. Use either Decorator or Observer patterns to inject the plugin's behavior or to notify the plugins of events occurence. Strategy might be applicable in some cases as well.

PHP makes this fairly easy at a potential cost of making a mess if you're not careful. I like the Observer method where plugins register themselves to a plugin manager which notify them of what happened and wait for their action to happen.

If you don't trust plugins then you'd have to put add controls over which events you are going to allow any plugin to register for.

  • 38
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions