您好,欢迎访问一九零五行业门户网

phalcon框架模板设置必须以phtml?

phalcon框架模板设置必须以phtml?
我设置index.html之后,刷新页面出现index.html.php
我想知道何解啊
而且我想知道在依赖注入那块
为什么不能在models里用$this->db,是这款框架设计的原因么?
回复内容: phalcon框架模板设置必须以phtml?
我设置index.html之后,刷新页面出现index.html.php
我想知道何解啊
而且我想知道在依赖注入那块
为什么不能在models里用$this->db,是这款框架设计的原因么?
1、模板后缀可以设置
参见:phalcon激活volt
2、依赖注入,实现全局懒惰加载 lazy load
注册模板引擎: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;});
在model里面引用注册的服务:php $this->getdi()->get('db')->.......
其它类似信息

推荐信息