Installing Smarty on Windows
This document assumes that you have configured PHP5, Apache Webserver already.
- Download Smarty
- Unzip the content of Smarty zip file to smarty folder. So it appears as C:/server/smarty
- Create two folders templates_c and cache inside it. So it appears as C:/server/smarty/templates_c and C:/server/smarty/cache
- Browse to PHP Installation Directory and edit php.ini's include_path and add the location of the libs folder. Example: include_path = ".;C:/server/smarty/libs/;"
- Restart IIS/Apache
- Create a new folder in htdocs (root) folder and rename it to smarty. C:\server\htdocs\smarty
- Create two folders configs and templates inside it. C:\server\htdocs\smarty\configs and C:\server\htdocs\smarty \templates
- Smarty configuration is done. Create two scripts index.php and index.tpl to test Smarty template engine.
- Place index.php inside C:\server\htdocs\smarty and index.tpl inside C:\server\htdocs\smarty \templates
- Open the web browser and type in the URL http://localhost/smarty.
index.php
<?php
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = ‘C:\server\htdocs\smarty \templates’;
$smarty->conf ig_dir = ‘C:\server\htdocs\smarty\configs’;
$smarty->cache_dir = ‘C:/server/smarty/cache’;
$smarty->compile_dir = ' C:/server/smarty/templates_c’;
$smarty->assign('name','Lucky!!');
$smarty->display('index.tpl');
?>
index.tpl
<html>
<body>
Hello, {$name}
<body>
<html>