Phoenix app that manages plugins

Hi
I mostly used Ruby/Rails, so I understand MVC etc
A project called: “Redmine” is developed in Rails. It has support for plugins.
I want to create a simple demo of app that manages a plugins similar to Redmine.

Let’s say i create a demo app like this:

> mix phoenix.new example
> cd example
> mix phoenix.gen.html Plugin plugins dir_name:string is_active:boolean
> nano web/router.ex

and change line:

get "/", PageController, :index

to:

resources "/", PluginController

then create a “plugin”:

> mkdir plugins
> cd plugins
> mix phoenix.new first

I want to run a plugin as a separate app or as a plugin for main project that manages them.
Results I expect:

> cd example
> mix phoenix.server

  localhost:4000 # list of plugins
  localhost:4000/plugins/first/ # hello from first plugin

> cd plugins/first
> mix phoenix.server

  localhost:4000 # hello from first plugin

Can you help me with this?

2 Likes

I am wondering this as well. The example I would give is WordPress-style plugins where all the models, views and controllers are embedded in the plugin and discoverable by a Phoenix “app.” You seem to have captured the UX-side of it well: each plugin could itself be a self-contained Phoenix app.

I’d probably make each plugin its own application that just calls to a global registration process.

2 Likes

I’m going to create a WebSocket based page, but my future code could be modified for Controllers.
I have finally a good idea. I will save it in database with (generated relative url, role, channel and room name).
In my parser WebSocket channel I will find a menu item by role, check associated user role and if them match I will respond something like:

{:ok, {channel, room}}

or

{:error, status_code} # for example 404

Then JavaScript should just get data from returned channel and room names, parse it and add to view.
:smile: