The phalcon framework template must be set with phtml? After setting index.html, click "index.html. php: I want to know what the solution is. I want to know why $ this-& amp; gt; db cannot be used in models in the dependency injection module, is this framework designed?
The phalcon framework template must be set with phtml?
After setting index.html, click "index.html. php" on the page.
What can I do?
And I want to know
Why can't I use $ this-> db in models? Why is this framework designed?
Reply content:
The phalcon framework template must be set with phtml?
After setting index.html, click "index.html. php" on the page.
What can I do?
And I want to know
Why can't I use $ this-> db in models? Why is this framework designed?
1. You can set the template suffix.
See Phalcon activation volt.
2. Dependency injection for global lazy load Loading
- Register the template engine:
php
/** 2. view */$di->setShared('view', function() use ($config) { $view = new \Phalcon\Mvc\View(); $view->setViewsDir($config->application->viewsDir); $view->registerEngines([ '.phtml' => '\Phalcon\Mvc\View\Engine\Php', '.volt' => function($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $volt->setOptions(['compiledPath' => $config->application->cacheDir . 'view/', 'compiledExtension' => '.compiled', 'compileAlways' => true ]); $compiler = $volt->getCompiler(); $compiler->addFilter('floor', 'floor'); $compiler->addFunction('range', 'range'); return $volt; }, ]); return $view;});
- Reference the registered service in the Model:
php
$this->getDI()->get('db')->.......