首页 > 系统服务 > 详细

mac下yii2安装Smarty模板

时间:2016-10-26 13:57:41      阅读:653      评论:0      收藏:0      [点我收藏+]

在项目根目录输入命令: php composer.phar require --prefer-dist yiisoft/yii2-smarty

如果报错 Could not open input file: composer.phar 则重新输入命令:omposer  require --prefer-dist yiisoft/yii2-smarty

技术分享

config下web.php的components里进行配置:

        ‘view‘ => [

            ‘renderers‘ => [

                ‘tpl‘ => [

                    ‘class‘ => ‘yii/smarty/ViewRenderer‘,

                //‘cachePath‘ => ‘@runtime/Smarty/cache‘,  

                ],

            ],

        ],

控制器 controller.php:

public function actionIndex(){       

        return $this->renderPartial(‘index‘, [‘text‘ => ‘ world!‘]);  

 }

模板 index.php:

hello{$text}

会输出:hello world!

mac下yii2安装Smarty模板

原文:http://www.cnblogs.com/facetwitter/p/5999868.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!