Smarty and XAMPP configuration on Windows
Smarty is a web template engine for PHP. It
is helpful for web project that are performs by different people(e.g.
programmer and designer). Smarty separates PHP from HTML, application
logic and content from its presentation.
Configuration:
1. Download the latest XAMPP version from http://www.apachefriends.org/
2. Install at C: directory. (C:\xampp)
3. Create a new folder in xampp folder and rename it to smarty. (C:\xampp\smarty)
4. Download the latest Smarty version from http://www.smarty.net/
5. Unzip the content of Smarty zip file to smarty folder. (C:\xampp\smarty)
6. Create two folders templates_c and cache inside it. (C:\xampp\smarty\templates_c and C:\xampp\smarty\cache)
7. Open php.ini file (C:\xampp\php\php.ini), search for Paths and Directories. At Windows part, replace the line
- include_path = ".;C:\xampp\php\pear\"
- with
- include_path = ".;C:\xampp\php\pear\;C:\xampp\smarty\libs\"
9. Create two folders configs and templates inside it. (C:\xampp\htdocs\smarty\configs and C:\xampp\htdocs\smarty\templates)
10. Smarty configuration is done. Create two scripts index.php and index.tpl to test Smarty template engine.
11. Place index.php inside C:\xampp\htdocs\smarty\ and index.tpl inside C:\xampp\htdocs\smarty\templates\
- index.php
- <?php
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty-»template_dir = 'C:/xampp/htdocs/smarty/templates';
$smarty-»config_dir = 'C:/xampp/htdocs/smarty/config';
$smarty-»cache_dir = 'C:/xampp/smarty/cache';
$smarty-»compile_dir = 'C:/xampp/smarty/templates_c';
$smarty-»assign('name','Penguin !!');
$smarty-»display('index.tpl');
?>
- index.tpl
- <html>
<body>
Hello, {$name}
<body>
<html>