We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

multi module does not auto render

hi. first excuse me for my weak english. single application does auto render but i try the https://docs.phalcon.io/en/latest/reference/applications.html#multi-module tutorial. controller is executed but does not auto render view files.

Meanwhile all paths are correct and i try Phalcon\Mvc\View\Simple for manual render it does render. i like so much phalcon framework tank you for this great work.



98.9k

Hi, you can use album-o-rama as an example of https://album-o-rama.phalcon.io/, source code: https://github.com/phalcon/album-o-rama



688

this application works very well . i compared source codes but i can not found problem. i use php engine. my Module class ` <?php namespace Frontend;

use Phalcon\Loader, Phalcon\Mvc\Dispatcher, Phalcon\Mvc\View, Phalcon\Mvc\ModuleDefinitionInterface;

class Module implements ModuleDefinitionInterface {

/**
 * Register a specific autoloader for the module
 */
public function registerAutoloaders()
{

    $loader = new Loader();

    $loader->registerNamespaces(
        array(
            'Frontend\Controllers' => realpath(__DIR__.'/controllers'),
            'Frontend\Models'      => realpath(__DIR__.'/models'),
        )
    );
    $loader->register();
}

/**
 * Register specific services for the module
 */
public function registerServices($di)
{
    //Registering a dispatcher
    $di->set('dispatcher', function() {
        $dispatcher = new Dispatcher();
        $dispatcher->setDefaultNamespace("Frontend\Controllers");
        return $dispatcher;
    });

    //Registering the view component
    $di->set('view', function() {
        $view = new View();
        $view->registerEngines(array(
            ".phtml" => "Phalcon\Mvc\View\Engine\Php",
        ));

        $view->setViewsDir(realpath(__DIR__.'/views/'));
        $view->setLayoutsDir('/layouts/');
        $view->setMainView('index');

        return $view;
    });

}

} ` is it true settings? i dont understand what is the problem Because controller is executed and displays strings with 'echo' in action method but does not auto render. tank you for guidance.



688

tank you again for guidance. it was problem in my code 'realpath' ` $view->setViewsDir(realpath(DIR.'/views/')); ` and i change to ` $view->setViewsDir(DIR.'/views/'); `