Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wilon opened this issue Mar 7, 2017 · 0 comments
Open

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

wilon opened this issue Mar 7, 2017 · 0 comments
Labels

Comments

@wilon
Copy link
Owner

wilon commented Mar 7, 2017

安装:

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

@wilon wilon added the php label Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant