Skip to content

Composer安装smarty3.1,配置使用 #3

Description

@wilon

安装:

composer require smarty/smarty

使用:

<?php
//开启调试模式
define('APP_DEBUG', true);
//入口文件目录绝对路径
define('SITE_ROOT', str_replace('\\', '/', __DIR__));
//数据缓存目录绝对目录
defined('DATA_PATH') or define('DATA_PATH', SITE_ROOT . '/data');
//包含自动加载类
$loader = require './vendor/autoload.php';
//smarty实例化
$smarty = new \Smarty;
//$smarty->left_delimiter = "{#";
//$smarty->right_delimiter = "#}";
$smarty->setTemplateDir(SITE_ROOT . '/views/'); //设置模板目录
$smarty->setCompileDir(SITE_ROOT . '/data/cache/templates_c/');
$smarty->setConfigDir(SITE_ROOT . '/views/smarty_configs/');
$smarty->setCacheDir(SITE_ROOT . '/data/cache/smarty_cache/');
//$smarty->force_compile = true;
if (APP_DEBUG) {
	//$smarty->debugging      = true;
	$smarty->caching        = false;
	$smarty->cache_lifetime = 0;
} else {
	//$smarty->debugging      = false;
	$smarty->caching        = true;
	$smarty->cache_lifetime = 120;
}
$smarty->assign('title', '标题');
$smarty->display('index.html');
?>

原文:使用composer安装smarty3.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions