Is it possible to share Web stuff between two phoenix apps under one umbrella app?

Hi all,

I’m currently working on an Umbrella app that has two phoenix web applications inside, and a third app which handles most of the business logic for both apps.

It’s something like this:

- apps/
      - phoenix_web_app_1/
      - phoenix_web_app_2/
      - business_logic_app/

How can I share some common web stuff (i.e. plugs/controllers/views/templates) between phoenix_web_app_1/ and phoenix_web_app_2/?

business_logic_app doesn’t have anything related to the web so I would prefer not adding the common stuff in there.

Would anyone be able to point me in the right direction?

Thank you!

How about a fourth application?

Yes, but how would the 4th application be? A phoenix web app?

How do I reuse the things inside this app (i.e. a template) on the other two?

If you don’t need Application or Supervisor, an app generated by mix new would be enough.

For example:

$ cd apps
$ mix new share  # name it what you want

Then, in your two phoenix apps, you can use the share app as a dependency:

# apps/phoenix_web_app_1/mix.exs and apps/phoenix_web_app_2/mix.exs

def deps do
  [
    {:share, in_umbrella: true}
    # ...
  ] 
end

In the end, just maintain the share app, play with modules and functions. That’s all.

It’s all modules and functions eventually. Use those modules and their functions.