The phalcon framework template must be set with phtml?

Source: Internet
Author: User
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

  1. 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;});
  1. Reference the registered service in the Model:
php    $this->getDI()->get('db')->.......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.