I just upgrade to Phalcon3.0.1
My project structure like this:
project
|-- mod1
| |-- controllers
| | |-- FirstController.php
| |-- views
| | |-- first
| | | |-- index.phtml
| |-- Bootstrap.php
|-- mod2
| |-- controllers
| | |-- SecondController.php
| |-- views
| | |-- second
| | | |-- index.phtml
|-- views
| |-- layouts
| | |-- layout.phtml
| |-- main.phtml
|-- config
| |-- serivces.php
I set up $di['view'] in services.php and mod1/Bootstrap.php both
In services.php
$di->setShared('view', function () {
$config = $this->getService('config')->resolve();
$view = new View();
$view->setViewsDir( [$config->application->viewsDir] )
->setLayoutsDir( $config->application->layoutsDir )
->setLayout( $config->application->layoutName );
return $view;
});
In mod1/Bootstrap.php
public function registerServices(\Phalcon\DiInterface $di = null)
{
/**
* Update the view component
*/
$v = $di->get('view');
$path = $v->getViewsDir();
$path[] = __DIR__ . '/views/';
$v->setViewsDir( $path );
$di->setShared('view' , $v);
}
But it will render layouts/layout.phtml twice and mod1/views/first/index.phtml one time
Why??