Hi guys! I'm having a big problem with Phalcon Multimodule app. I've read in docs and tutorial that it is possible to replace the
echo $application->handle()->getContent();
with a bunch of lines that do the same things in a more splitted way so the developer could have more control on what is executed and at debug time too.
This works good with single App, but don't work at alla with multiple modules apps as the Module registration code is completely skipped... i mean that the registration add the modules to the internal array (infact $applicaton->getModules(); return a correct full array) but the single Modules class code are never instantiated (and so neither the internal interface method to register Autoloader and Services)... This makes any url requested return that nice error "IndexController handler cannot be found".
I discovered the registered moduler are not instantiated debugging with XDEBUG... it never entered the Modules initialization code and infact this is verified also by the error... he can't find the controller because the controllers are registered in the registerAutoloaders() function of modules that are not yet initialized (and also the error give the wrong message as it is missing the namespace of the controller it should really load).
Here is the code i'm using after the modules registration to perform the request.
// Get the 'router' service
$router = $application->router;
$router->handle();
$dispatcher = $application->dispatcher;
// Pass the processed router parameters to the dispatcher
$dispatcher->setControllerName($router->getControllerName());
$dispatcher->setActionName($router->getActionName());
$dispatcher->setParams($router->getParams());
// Dispatch the request
$dispatcher->dispatch();
//Get the returned value by the lastest executed action
$response = $dispatcher->getReturnedValue();
//Check if the action returned is a 'response' object
if ($response instanceof Phalcon\Http\ResponseInterface) {
//Send the request
$response->send();
}
My suspect are that this is a bug because in various topics over internet i've read that modules are instantiated during module registration... or maybe that $application->handle()->getContent(); do something more than what documentation suggest to replace with... so if this is not a bug, i think i'm skipping some line in my code to raise the module instantiation... and if i'm skipping some line it is missing in the documentation so please post it here.
PS. yes, using echo $application->handle()->getContent(); my multimodule app works great.
thanks in advance for support.