I have a Phalcon project set up and I have a working implementation of multiple Controller directories. My current directory structure is simple and looks like this:
/controllers
/admin
ControllerBase.php
IndexController.php
AuthController.php
ControllerBase.php
IndexController.php
To get this working, I registered two namespaces:
$loader->registerNamespaces(
array(
'App\Controllers' => APP_PATH .'/controllers/',
'App\Controllers\Admin' => APP_PATH .'/controllers/admin/',
...
));
While this works, the following 2 issues present themselves when creating a large application with multiple directories:
The main problem I'm having is #2, it seems no matter what I try I cannot have /admin/IndexController.php inherit from /ControllerBase.php. It will only allow me to inherit from the /admin/ControllerBase.php.
Because it seems to work:
I have multiple namespaces (multiple paths) and many controllers (with or without namespace) that inherits from one ControllerBase
(which has no namespace). So it's doable.
As far PHP is able to load your classes you should be able to have only one ControllerBase
.