Hi,
I started a project but it seems that I need a structure like this on it because I have many Controllers and Modules and Views: https://i.stack.imgur.com/72SAX.png
I tried to structure the project but I don't know exactly how to manage this with namespaces and routes.
I have something like this in config file:
'application' => [
'controllersDir' => APP_PATH . '/controllers/',
'modelsDir' => APP_PATH . '/models/',
'formsDir' => APP_PATH . '/forms/',
'viewsDir' => APP_PATH . '/views/',
'helperDir' => APP_PATH . '/helper/',
'libraryDir' => APP_PATH . '/library/',
'pluginsDir' => APP_PATH . '/plugins/',
'cacheDir' => BASE_PATH . '/cache/',]
In loader:
$loader->registerNamespaces([
'MyApp\Models' => $config->application->modelsDir,
'MyApp\Controllers' => $config->application->controllersDir,
'MyApp\Forms' => $config->application->formsDir,
'MyApp' => $config->application->libraryDir
]);
$loader->register();
In services:
$di->set('dispatcher', function () {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('MyApp\Controllers');
return $dispatcher;
});
I see this on the internet https://github.com/phalcon/mvc/tree/master/simple-subcontrollers but I still try to understand what we need to manage the namespaces and the routes, is someone here who can explain me in a simple way easy to understand or if you have another structure as example maybe will help others not only me. What I see here it is that https://github.com/phalcon/mvc/tree/master/simple-subcontrollers every folder has a ControllerBase inside so I don't need to make for every folder a ControllerBase I don't want to make 100 ControllerBases. How to use routes and namespaces to send the information corectly to every view even if we have folders inside too.
Thanks!