How can i create a php plugin system in php scripts

Discussion in 'PHP' started by bweb11, Jul 25, 2009.

  1. #1
    Hi, can someone please explain as simply as possible to to create a php plugin system, i have read:

    http://stackoverflow.com/questions/217659/build-a-plugin-system-with-php
    http://www.sitepoint.com/forums/showthread.php?t=379440

    and all the links on them, but they haven't really helped. All i have now gathered is that to do this, i probably have to write the classes that all the plugins will be able to use. I don't know how the plugins would be activated and how to do this all securely.

    Thanks
     
    bweb11, Jul 25, 2009 IP
  2. Chikey.ru

    Chikey.ru Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    for what the system needs a plug?
     
    Chikey.ru, Jul 25, 2009 IP
  3. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The best method will be creating a directory named "plugins" and inside that directory create the plugins with a specific format.

    For example the plugin file name should be some thing like PluginYourclass.php

    and each time when your application is loaded or plugins are called check inside the plugins directory and also check for the file name which starts with Plugin and load those classes. Inside the classes you will have to create options for creating the db or other objects if needed. Or you can create a common parent class which will do this job for you

    Thanks!!
     
    HivelocityDD, Jul 25, 2009 IP
  4. bweb11

    bweb11 Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks HivelocityDD, that has helped. Anyone else have any info?
     
    bweb11, Jul 25, 2009 IP
  5. bweb11

    bweb11 Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If for example i created a script that connects to a database and retrieves the alphabet from a to z. Echoing them on screen, and someone wanted to create a plug-in that would say every 3 letters print there have been 3 letters and after the next 3 there have been 6 letters.

    If for instance the script before getting the alphabet, gets the sitename, homepath, and webpath from the database, after which it then gets the alphabet, how would a plugin that is meant to do something after it gets the sitename and so on but before the alphabet do this.
     
    bweb11, Jul 26, 2009 IP
  6. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #6
    See and learn how WordPress handles plugins.
     
    stOK, Jul 26, 2009 IP
  7. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #7
    I have created a few plugin systems. Normally, I would use the database in conjunction with scripts and read the scripts. Any plugin with type "page" would become a loadable page if you went to plugin.php?page=PLUGIN_NAME (page=$name would retrieve the plugin file). If it was a sidemodule (provided this is CMS like) then you can add the information into a block. Finally, if it's a class or other, just have it load in the header of the site for each page.

    I also prefer to use ZipArchive to compress and decompress the mods when they're uploaded.

    Regards,
    Dennis M.
     
    Dennis M., Jul 26, 2009 IP
  8. bweb11

    bweb11 Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks. I did look at wordpress before making this thread but, it didn't really help. I looked at the backup wordpress plugin.
     
    bweb11, Jul 31, 2009 IP