[Catalyst-dev] Extensible Catalyst Applications: How?!

Ido Perelmutter ido50 at yahoo.com
Tue Jun 2 10:45:28 GMT 2009


Hi everyone.

For the last week and a half I've been trying to figure out how to make my Catalyst application extensible, to no avail.

SCENARIO:

1. I have written a Catalyst application called MyApp (The name is a trademark belonging to me so don't steal it).

2. I want people (and me too) to be able to create plugins that extend the functionality of MyApp.

3. I want to create a plugin for MyApp, called "MyPlugin". This plugin in itself is a (near-)complete Catalyst application. It has its own controllers, models, views, etc.

4. I want to "mount" this plugin to some path on MyApp, such that all requests for a path beginning with "/myplugin", for example, are to be routed to MyPlugin's controllers.

5. The context is, of course, to be shared between the two. MyPlugin is seamlessly integrated into MyApp, but any MyPlugin logic is not to be added to MyApp. For example, I do not need to change MyApp.pm to add some MyPlugin specific code, like $c->controller eq $c->controller('MyPlugin::ShootMe') for example.

6. MyPlugin is to be, well, pluggable. I can enable and disable it as/when I wish.

WHAT I'M DOING NOW:

1. I develop MyPlugin as an integral part of MyApp, making all it's controllers MyApp-controllers, and update myapp.conf appropriately (adding a realm perhaps and MyPlugin-related configurations).

2. I add MyPlugin logic to MyApp.pm and maybe other files.

3. I shoot myself in the head.

WHY THIS IS BAD:

1. It's not pluggable.

2. I have interfered with MyApp's code (including myapp.conf) - very bad for development. While one (MyPlugin) depends on the other (MyApp), they should be separate entities.

3. I have shot myself in the head, that can't be good.

So, my question is, what am I to do in order to make my app extensible, at least in the way described above? Do I definitely need to create an API for MyApp? (I will anyway, but is that necessary for the scenario above?).

And also, how can I overcome potential problems like MyPlugin requiring the presence of Catalyst plugins not loaded by MyApp.pm?

Any help heavenly appreciated,
Ido Perelmutter.


      



More information about the Catalyst-dev mailing list