natacha
natacha

Reputation: 13

How to access a controller from a different module?

I have a Phalcon Multimodule App with the following structure:

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 :)

Upvotes: 0

Views: 2011

Answers (1)

Zikes
Zikes

Reputation: 5886

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

Upvotes: 1

Related Questions