Share on Google+Share on Google+

Installing Smarty Templates for PHP Program

Learn how to install Smarty Template for your PHP program.

Installing Smarty

In this section we will show you how easily you can download and install Smarty Template in your project.

What are the basic requirements for installation Smarty?

 The requirements and installation process are given below:

  •    Requirements

        A web server running PHP 4.0.6 or advance

  •    Basic Installation

        From the directory of distribution (/libs/) install the Smarty library files.

        Architecture of Smarty library files is:

  • Smarty.class.php

  • Smarty_Compiler.class.php

  • Config_File.class.php

  • Debug.tpl 

Smarty uses a PHP constant name SMARTY_DIR which is the system file path Smarty library directory. You can set this directory in the php.ini file if you have root access of the system. If you don't have root access to the system then you can copy the smarty library in your project workspace include the Smarty library wherever you need the Smarty framework.

For example:

require './libs/Smarty.class.php';
$smarty = new Smarty;

$smarty->caching = true;
$smarty->assign('Article', "Roseindia is a good software Development company");



Quick Guide to install Smarty

Here are the quick steps to download and install the Smarty library into a PHP web application.

Step 1: Download Smarty

Download the Smarty Template Library from

Step 2: Extract the downloaded .zip file

After extracting the .zip file to your desired folder, for this example I have extracted it into c:\mysmart folder.

Step 3: Create necessary folders

a) Create  a new directory (smarty) under www folder of the wamp. 

b) Copy the lib directory from the Smarty unzip directory into C:\wamp\www\smarty\ folder.

c) Create three folders namely templates, cache, templates_c under C:\wamp\www\smarty

We will develop and place our template files under templates folder. The cache and templates_c folders are used by the Smarty engine.

Step 4: To create Smarty template:

Now you can develop the .tpl files and then save under the templates directory.

Step 5: To access the php file:

Finally you can use the .tpl file in your PHP program. Now you can start the WAMP server and start developing the program.

In the next section I will show you how you can develop the Hello World application using Smarty Template.


Posted on: October 8, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.