0
votes

I have a Phalcon Multimodule App with the following structure:

  • appServer
    • apps
      • api
      • backend
      • web
    • config
    • public

The backend module is my common logic module. (I think that) I need a Controller in the API to call a Controller inside backend. How can I do that? or is there a better way to access the logic within the backend module from the api module?

I have already tried adding the \AppServer\Backend\Controllers namespace to the loader inside \AppServer\Api\Module->registerAutoloaders(), but when I tried to use it inside \AppServer\Api\Controllers\IndexController->index(), it gives me an error saying it couldn't find the class.

I've read that I should get the processed module from the router, but I don't know how to do that either.

Thanks in advance for your help :)

1
What you want to achieve? Maybe there's other solution for your problem but I'm not sure if I understand your problem correctly. Do you want redirect user to other controller's action or do you share some common logic between modules? - jodator
Sorry for the delay, I'll have to check my notifications options.... I'm trying to put common logic and models in just one place, put some special logic specific to the API in one place, and special logic specific to the web interface in a different place. The main thing here is, the users accessing the API are not the same ones accessing the webUI, but they both access the same models and some common logic. - natacha

1 Answers

1
votes

Use this structure:

  • appServer
    • apps
      • api
      • backend
      • web
    • common
      • models
      • controllers
      • views
    • config
    • public

Here is an example application that uses a similar application structure: https://github.com/phalcon/album-o-rama