首页 > php框架 > Windows下Smarty的安装

Windows下Smarty的安装


下载解压缩就不用说了

官方网站:http://smarty.php.net

php.net也有相关资料:http://news.php.net/php.smarty.dev/2703

Installation - Windows, IIS/Apache, PHP5

Extract files, rename Smarty.x.x.x to smarty (suggest OUTSIDE of your www root!)

Example: D:smarty

Run phpinfo.php to find out your php.ini location

//这个phpinfo.php在哪里?没找着,不Run也罢,往下看。


Edit php.ini's include_path and add the location of the libs folder. 

//修改php.ini 查找include_path这个字段,照下面的方式修改,目录名称及路径自己定义,只要与实际解压目录的路径相同就OK了。

example: include_path = ".;D:smartylibs" 

Restart IIS/Apache


Setup these two folders INSIDE your www root:

//在WEB服务器根下建立templates和configs这两个文件(smarty目录也是自己建的)

(wwwroot)/smarty/templates  (this is where your templates will go)

(wwwroot)/smarty/configs


Setup these two folders OUTSIDE of your www root:

//在smarty的解压目录建立templates_c和cache这两个目录。

D:/smarty/templates_c

D:/smarty/cache


Setup security settings for the webserver to write to these four folders

//templates 、configs 、templates_c 、cache 这四个目录必须是可写权限


In (wwwroot) create index.php and in (wwwroot)/smarty/templates/index.tpl with the following code:

//创建index.php及index.tpl两个文件测试Smarty是否安装成功,代码如下:


index.php:

PHP代码:

<?php
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'D:/inetpub/wwwroot/smarty/templates';
$smarty->config_dir = ' D:/inetpub/wwwroot/smarty/config';
$smarty->cache_dir = 'D:/smarty/smarty_cache';
$smarty->compile_dir = 'D:/smarty/smarty_templates_c';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>

index.tpl

复制内容到剪贴板

<html>
<body>
Hello, {$name}!
</body>
</html>

Now open index.php in your web browser (requested from your webserver)

//现在运行index.php,如果看到"Hello, fish boy!! "说明安装成功


本文地址:http://www.phprm.com/frame/4dd0f1f96b7cd3f47c755f91ee56bbe9.html

转载随意,但请附上文章地址:-)

标签:none

发表留言