EllisLab text mark
Advanced Search
1 of 2
1
   
Codeigniter Hook Based Plugin System
Posted: 08 March 2011 11:09 PM   [ Ignore ]
Avatar
Joined: 2010-08-08
304 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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 09 March 2011 08:12 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 09 March 2011 01:09 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2010-01-07
179 posts

I have a comment smile 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 smile

Keep up the great work dude.

peace !

 Signature 

Follow Me On Twitter!

Dove Forums - PHP/MySQL Discussion Forums built on CodeIgniter

Dove Forums - PHP/MySQL Forums Software

 
Posted: 11 March 2011 08:15 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-04-27
169 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`) 
 
Posted: 11 March 2011 09:57 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 14 March 2011 11:29 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 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' 
 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 16 March 2011 07:24 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2007-03-18
51 posts

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

 
Posted: 09 August 2011 09:08 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-24
119 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

 Signature 

Everything’s under control…

 
Posted: 09 August 2011 10:22 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 posts
Timothy_ - 10 August 2011 01:08 AM

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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 10 August 2011 12:46 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-24
119 posts

Hello,

Thanks for responding.

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

Is that enough info?

Thanks

Tim

 Signature 

Everything’s under control…

 
Posted: 10 August 2011 02:01 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 10 August 2011 02:03 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-24
119 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

 Signature 

Everything’s under control…

 
Posted: 10 August 2011 02:34 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-08
304 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.

 Signature 

Plenty Parser - Parser library WolfAuth - Role Based Authentication library | CI Smarty - Smarty integration for Codeigniter 2.0+ | CI Plugins System - A simple hooks system.

 
Posted: 10 August 2011 04:51 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-24
119 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

 Signature 

Everything’s under control…

 
Posted: 14 August 2011 09:23 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-24
119 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

 Signature 

Everything’s under control…

 
Posted: 17 August 2011 01:06 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-24
119 posts

Hello,

I have tracked down the line where your library is crashing.

Its line 184

// If the file was included
@include_once $this->plugins_dir.$name."/".$name.".php"

I echoed $this->plugins_dir.$name.”/”.$name.”.php”; and the paths seems fine.

I appreciate that you are probably very busy, however it would be great if you could give me an indication if you are likely to pursue this in the near future.

Thanks,

Tim

 Signature 

Everything’s under control…

 
1 of 2
1