如何将Mustache模板引擎集成到Phalcon PHP 3应用程序中以使用它而不是内置电压?
最好的主意是composer
为了获得Phalcon孵化器-一组额外的Phalcon集成库,其中还包含Mustache实现。
怎么做:
curl -s http://getcomposer.org/installer | php
{ "require": { "phalcon/incubator": "~3.0" } }
如果您使用的是Phalcon 2.0.x,请改用: { "require": { "phalcon/incubator": "~3.0" } }
php composer.phar install
require_once APP_PATH . '/vendor/autoload.php';
我通常将此行添加到中config/loader.php
,但这取决于您的项目结构。在视图组件中将胡须设置为渲染器
//Setting up the view component
$di->set('view', function() {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/views/');
$view->registerEngines(
['.mhtml' => 'Phalcon\Mvc\View\Engine\Mustache']
);
return $view;
});
就是这样,您就完成了。
您可以在Incubator github页面和Mustache实现页面上阅读更多信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句