TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Module: Kohana Plugin System
  • This module I've written allows you to add a Wordpress like plugins system to your Kohana applications. It originally started out as a Codeigniter library, but having recently moved to Kohana as of a few days ago, I've ported it over as I could only find events modules for Kohana and not plugin systems. Please let me know what you think and don't be afraid to make improvements: https://github.com/Vheissu/Kohana-Plugin-System

    I may have made some obvious mistakes, Kohana is quite different to CI and I am new to the premise of the cascading filesystem and way modules are constructed but I am learning. Hopefully someone finds this useful.

  • Sounds good! I've always thought about doing a thing like that.

    You might want to add it to https://github.com/ahutchings/kohana-modules

  • The things here should be at the top level of the repository: https://github.com/Vheissu/Kohana-Plugin-System/tree/master/plugins

  • Yes, good point zombor.

    And is the idea that the plugins directory would be at the application's top level, next to modules?

    (oh, and tiny issue in the licence file where there's still a placeholder)

  • Yes, you'd clone (or copy) the repository itself into a "plugins" directory inside of modules. The way it's setup right now, I can't clone the repo into a modules directory and expect it to work as expected.

  • @samwilson — I've never added a submodule to another repository before, how do I go about doing that? Do I fork, edit the submodules file and then do a pull request? Just noticed the placeholder, thanks!

    @zombor — Thanks mate. I've just moved them to the top level. Wasn't entirely sure where they should be within the repository.

  • Yep, that's it! See http://kohana-modules.com/pages/add-a-module

    So @Vheissu, the basic operation of the plugin module is to hook in with Plugins::add_action("action_name", "function_to_call", $priority); and then run it in the location it's required with Plugins::do_action(...) ?

  • @samwilson — Ah, didn't see that link, thank you. Yep, that's exactly how it works. It's an events system essentially bundled with a file including layer. I originally aimed to replicate how Wordpress handles events using functions; add_action, do_action and had it working that way in Kohana but given Kohana works in a way you need to use empty alias/empty classes, procedural functions didn't seem to really work with how Kohana is built.

    So Plugins::add_action("action_name", "function_to_call", $priority); registers the event/hook and Plugins::do_action(...) is what you would put in various places you want the user to be able to hook in and change things. It's not a fancy library, but it's served me well over the years.

  • Do you mean for them to be called statically? Because they're not static at the mo'. So it's Plugins::factory()->do_action('blah') instead?

  • @samwilson — Good pick up, thank you. I think a recent pull request made some functions that were static normal functions. I've just pushed a fix.

  • A nice little update was pushed, the event system and plugin manager(which can be config-based or database-based) are now separate. The module also comes bundled with an example UI to manage the plugins.

  • @Happydemon,

    You've done an amazing job my friend. Thank you for your contributions, the plugin module is now way better than it ever was.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion