Create a components/helpers folder inside your module and import it from inside your module(setImport() in init() method). Then in your helpers folder you can have static classes that can help you inside your module.
I think from outside the module, you shouldn’t access models/ components that are shipped with the module. Think of the module as a black box. The outside world shouldn’t know about its internal structure. Otherwise, you can never refactor your module.
If it’s necessary, because the interface of the module grows to large, you can do:
From within your module, you work nearly the same as with an ordinary application. For example in one of your module’s controllers, you can do:
$myModule = $this->module;
$myModuleComponent = $this->module->componentName;
// if your module doesn't define the component, the module will look
// if its parent (normally the application) defines the component
$someApplicationComponent = $this->module->componentName;
What I always do in my modules is in its init() method:
public function init()
'_myModuleName' => dirname(__FILE__),
// import the module-level models and components
// better use this
// instead of this
The first version will actually create an instance of your module. While this might not necessarily be needed for every static method, many of them will probably use some components, models or other helpers that ship with the module. So by making sure you have an instance of the module created before running the methods, you also ensure that its init() method is run. And that is commonly the place where all the necessary setup for the module is placed, like for example all the import() calls.
If it is not nessesary to load entire module (especially a heavy module) then the second way is equal important. The module init (in my case) has a lot of work to do! So must be loaded only in a few cases. In summary both of ways are important according to web application needs.