ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Codeigniter Hook Based Plugin System

March 08, 2011 10:09pm

Subscribe [8]
  • #1 / Mar 08, 2011 10:09pm

    Vheissu

    278 posts

    We all love the Wordpress plugins system. The ability to define hooks that get called when particular actions happen and ability to pass through arguments as well? Recently while helping out Chris Baines with Dove Forums talk of a plugins system like Wordpress arose and so in a couple of hours work I’ve developed one.

    It’s sort of alpha and sort of beta. You can define actions and then trigger them in your application, your plugin functions are called. Creating plugins is in-fact so close to Wordpress that if you can create Wordpress plugins, you can use this library.

    Feel free to fork and make it better. It’s still early days, but it works. Check it out on the Github repository I created here. The repository has information on using it, but there is no documentation for this library yet as things keep changing.

    The basics of this are:

    * Autoload the library.
    * Register action hooks by using the add_action() function.
    * Trigger actions by run_action()

    That’s basically it, see the repo for more info.

  • #2 / Mar 09, 2011 7:12am

    Vheissu

    278 posts

    A slew of updates have been made to make this library better since posting this thread. Has anyone got any feedback? 40 views thus far and not a single comment, very strange. I would have thought plugin functionality was something lots of people wanted.

  • #3 / Mar 09, 2011 12:09pm

    Bainzy

    149 posts

    I have a comment 😊 it’s awsome ! lol

    But no mate like I keep saying, fantastic work.  Had a play earlier but going to sit down and take a good look tonight and have a play with what can be done.

    Can’t wait till we intergrate with Dove Forums and see what we can do with the system 😊

    Keep up the great work dude.

    peace !

  • #4 / Mar 11, 2011 7:15am

    quasiperfect

    132 posts

    hi

    i use latest reactor + Modular Extensions - HMVC version 5.4
    i downloaded the latest Codeigniter Hook Based Plugin System , run the sql file and autoloaded the plugin library

    i left only the helloworld plugin in the plugins dir
    i see lots of duplicate selects from the database

    0.0007      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0004      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0005      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0006      SELECT *
    FROM (`plugins`)
  • #5 / Mar 11, 2011 8:57am

    Vheissu

    278 posts

    Haha, yeah. It kind of has a few flaws at the moment. Planning on getting those sorted this weekend (within the next two days). The priority of things is a bit messed up, I call the same function for getting plugins quite a lot of times which is why that happens for the activation stuff, etc. I’m also going to add in some caching as well to alleviate the load on the database because if someone has 30 or even 15 plugins, their app will slow significantly.

    It’s a work in progress, an early beta version I guess you could say so things like this will pop up for the next couple of weeks until it’s stable. Thank you for letting me know though, very helpful feedback. Also feel free to fork and make changes yourselves as well, I’m open to all changes.

  • #6 / Mar 14, 2011 11:29pm

    Vheissu

    278 posts

    Can anyone help me out who’s good at profiling PHP code and pinpointing the location of duplicate queries? I’ve got the list of duplicate queries down to 2 now. The issue appears to be that the same plugin is searched for in the database twice, it must be within one of the foreach loops and is currently doing my head in.

    Anyone have any ideas and want to quickly help me out?

    Here’s what my profiler is now showing:

    0.0004      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'cimarkdown' 
    0.0003      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld' 
    0.0003      SELECT *
    FROM (`plugins`) 
    0.0002      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'cimarkdown' 
    0.0002      SELECT *
    FROM (`plugins`)
    WHERE `plugin_system_name` = 'helloworld'
  • #7 / Mar 16, 2011 7:24pm

    phpwebdev

    50 posts

    Can u show to us little more complex example on the plugin work

  • #8 / Aug 09, 2011 9:08pm

    Timothy_

    100 posts

    Hello,

    I am really excited by this library however no matter what I try i have been unable to get it working.

    I have added Plugins.php to my /application/libraries/ folder
    I then autoload the library in my /application/config/autoload.php file

    $autoload['libraries'] = array('plugins');

    I then get a global 500 server error. Removing the auto-load call removes the server error.

    I have successfully loaded other libraries but have removed them to make sure there is no clashes.

    Any advice would be greatly appreciated.

    Thanks,

    Tim

  • #9 / Aug 09, 2011 10:22pm

    Vheissu

    278 posts

    Hello,

    I am really excited by this library however no matter what I try i have been unable to get it working.

    I have added Plugins.php to my /application/libraries/ folder
    I then autoload the library in my /application/config/autoload.php file

    $autoload['libraries'] = array('plugins');

    I then get a global 500 server error. Removing the auto-load call removes the server error.

    I have successfully loaded other libraries but have removed them to make sure there is no clashes.

    Any advice would be greatly appreciated.

    Thanks,

    Tim

    What kind of server setup are you running Timothy? More specifically PHP version and Codeigniter version and we’ll go from there.

  • #10 / Aug 10, 2011 12:46am

    Timothy_

    100 posts

    Hello,

    Thanks for responding.

    PHP Version: 5.3.3-1ubuntu9.3
    Codeigniter Version: 2.0.2

    Is that enough info?

    Thanks

    Tim

  • #11 / Aug 10, 2011 2:01am

    Vheissu

    278 posts

    Did you also make sure from the download you included in the “plugins” directory which sits outside of the application directory by default? It’s possible that it can’t find the plugins directory and is failing.

  • #12 / Aug 10, 2011 2:03am

    Timothy_

    100 posts

    Yes I left that completely intact and the directory plugins is at root level /. The two example plugins are also located in there and I ran the sql script so I have the plugins table as well.

    Anything else I could be missing?

    Thanks for your help

  • #13 / Aug 10, 2011 2:34am

    Vheissu

    278 posts

    Hey, no worries! Hmm. This is a really troubling issue I haven’t seen happen before. It sounds like it could be server related, I’ll see if I can replicate on that particular version of PHP tonight, I’m just at work at the moment. What happens if you load the library manually in a test controller? Do you still get the 500 error or some other kind of error.

  • #14 / Aug 10, 2011 4:51am

    Timothy_

    100 posts

    Hey,

    Sorry about the delay in reply, I was also at work.

    Tried loading from within the controller and same error.

    Please let me know if you need anymore information.

    This is almost a clean install of CI 2.0.2 and as I have said other libraries seem to be working normally.

    Thanks,

    Tim

  • #15 / Aug 14, 2011 9:23pm

    Timothy_

    100 posts

    Hello Vheissu,

    Just wanted to see if you were able to reproduce the issue I am getting?

    If not could you perhaps tell me what version of PHP/CI you are using.

    I have tried doing a basic debug but it’s slow work because it is such a big library.

    Thanks,

    Tim

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases