It is easy to have multiple namespaces within your module. The only thing you need to do is to provide configuration to the Zend Autoloader(s). For the Zend\Loader\StandardAutoloader
the config can be set in the module and would look something like this:
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
// This is the default namespace most probably the module dir name
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
// And this is for your custom namespace within the module
'SomeNamespace' => __DIR__ . '/src/' . 'SomeNamespace',
'OtherNamespace' => __DIR__ . '/src/' . 'OtherNamespace',
),
),
);
}
For the Zend\Loader\ClassMapAutoloader
it is the same concept. You just need to match the namespaces to the class files:
// file: ~/autoload_classmap.php
return array(
'SomeNamespace\Controller\SomeController' => __DIR__ . '/src/SomeNamespace/Controller/SomeController.php',
'OtherNamespace\Controller\OtherController' => __DIR__ . '/src/OtherNamespace/Controller/OtherController.php',
);
Something to be caution about! Make sure that your submodule namespace's name doesn't collide with other modules namespaces.
Hope this helps :)
Stoyan