Installing Smarty in Windows

原创 2007年09月24日 08:12:00


This document assumes that your webserver and php5 is running.

Download Smarty - http://smarty.php.net

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
Edit php.ini's include_path and add the location of the libs folder.
example: include_path = ".;d:/smarty/libs"
Restart IIS/Apache
Setup these two folders INSIDE your www root:
(wwwroot)/smarty/templates (this is where your templates will go)
(wwwroot)/smarty/configs

Setup these two folders OUTSIDE of your www root:
d:/smarty/templates_c
d:/smarty/cache

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

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

index.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)

http://webserver/index.php

You can work this out to a referenced script/class:
smarty_connect.php:
<?php

// load Smarty library
require('Smarty.class.php');

class smarty_connect extends Smarty
{
function smarty_connect()
{
// Class Constructor.
// These automatically get set with each new instance.

$this->Smarty();

$this->template_dir = ' d:/inetpub/wwwroot/smarty/templates';
$this->config_dir = ' d:/inetpub/wwwroot/smarty/config';
$this->compile_dir = 'd:/smarty/templates_c';
$this->cache_dir = 'd:/smarty/cache';

$this->assign('app_name', 'Intranet');
}
}
?>

index.php:
<?php

require('smarty_connect.php');

$smarty = new smarty_connect;

$smarty->assign('name','Ned');

$smarty->display('index.tpl');
?>

index.tpl:
<html>
<body>
Hello, {$name}!
</body>
</html>


If you are getting an error that Smarty.class.php isn't found chances are that your include_path isn't correct or you didn't edit the one that the webserver is using, check your phpinfo.php!

 
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Installing CentOS 6 with Windows in a Dual Boot Environment

CentOS 6, in common with most Linux distributions, will happily co-exist on a hard disk drive with j...

[KVM] Installing Virtio drivers in a KVM Windows guest VM

KVM provides a Virtio interface for the virtual hard disk and NIC. To use them in a Windows guest VM...

Installing VMware Server & Windows in Linux

In a world dominated by Windows operating systems, migrating to Linux sounds a daunting task. Apart ...

Installing OpenCV 2.3.1 in Ubuntu

step1:下载 从http://sourceforge.net/projects/opencvlibrary 下载OpenCV源码,下载文件为OpenCV-2.3.1a.tar.bz2。 ...

Installing OpenCV 2.1 in Ubuntu

OpenCV is an excellent library for Computer Vision. I have been using it for years and it helped me ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)