thorbon
thorbon

Reputation: 35

Zend Framework 2: how do I access functions across modules?

I am not sure if this is possible, so please let me know.

I have a modular setup of Zend Framework currently with only 2 modules:

sms
web

application
--- /forms
--- /models
--- /modules
------/sms/
---------/models
------/web/
---------/models

Is it at all possible to access the functions (Models) in the SMS module from the WEB module?

Lets say I was in the IndexController in the WEB module and wanted to call the getData() Model in the SMS module, is this possible?

Upvotes: 1

Views: 1099

Answers (1)

Jaepil
Jaepil

Reputation: 390

More ZF2 specific way, using namespace, would be:

use MySmsModule\Model\MySmsModel;

class WebController extends ActionController
{
    public function indexAction()
    {
        $MySmsModel = new MySmsModel();
        $data = $MySmsModel->getData();

        ...
    }
}

Upvotes: 2

Related Questions