view is not displayed

Hello. Installed Phalcon 3.0.3 on Ubuntu 16.04 with php7. But the view of the file is not displayed, only the layout

class Module implements ModuleDefinitionInterface
{
    public function registerServices(DiInterface $di)
    {
        /**
         * Setting up the view component
         */
        $di->setShared('view', function () {
            $view = new View();
            $view->setViewsDir(__DIR__ . '/view/main/');
            $view->setLayoutsDir('../layout/');
            $view->setLayout('index');

            return $view;
        });
    }
}

Add __DIR__ to setLayoutsDir() also.

            $view->setViewsDir(__DIR__ . '/views/');
            $view->setLayoutsDir(__DIR__ . '/views/_layouts/');

I bealive I changed mine to this when switched to 3.0.



6.5k

@nikolay-mihaylov it didn't help

edited Dec '16

Try to debug your paths with get... methods from https://docs.phalconphp.com/en/3.0.1/api/Phalcon_Mvc_View.html.

I remember that I needed to fix the path to be relative to the file you define the service. In my case I had multimodule app and in my module I had the following structure:

/module/
    -- /views/
    -- /controllers/
    Module.php // (here i define services)


6.5k

@nikolay-mihaylov is it normal that getActiveRenderPath--/home/user/www/phalcon/app/module/test/view/main/index.phtml ?

getRenderLevel--5
getCurrentRenderLevel--0
getRegisteredEngines--Array ( [.phtml] => Phalcon\Mvc\View\Engine\Php )
getRegisteredEngines--Array ( [.phtml] => Phalcon\Mvc\View\Engine\Php )
getViewsDir--/home/user/www/phalcon/app/module/test/view/main/
getLayoutsDir--/home/user/www/phalcon/app/module/test/view/layout/
getPartialsDir--
getBasePath--
getMainView--index
getLayout--index
getControllerName--Welcome
getActionName--terms

Does the layout have a getContent() command in it? It has to pull in view content