Posted by: Md. Masud on: May 27, 2007
Installing Smarty in Windows
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!
hmm, why can’t i do that? i do exact things like you wrote, but it’s still not working…
“Parse error: parse error, unexpected T_CLASS in D:\Sakti-WebDesign\local\rzi-s-ver\index.php on line 3″
and that is the line of:
“require(’Smarty.class.php’);”
i really need this thing worked!
horeeyy…i finnaly worked it out, you cheat…
ukh.. it’s semicolon problem,..ukh,,,thank you anyway
I done some you have mention above for smarty but i m getting this problem.
Warning: Smarty error: unable to read resource: “index.tpl” in C:\Smarty\libs\Smarty.class.php on line 1092
help me?
I am getting problem.
Warning: Smarty error: unable to read resource: “index.tpl” in C:\smarty\libs\Smarty.class.php on line 1092
i really need help?
hi there, seems to be giving me an error but from :
arse error: parse error, unexpected ‘”‘ in C:\Program Files\EasyPHP 2.0b1\www\smarty\Smarty_Compiler.class.php on line 1757
i have done all that u said and included the path to the libs.
Please help !!!!
i was getting the same problem
Warning: Smarty error: unable to read resource: “index.tpl” in C:\smarty\libs\Smarty.class.php on line 1092
than I had chkd my index.php file and I get that the path i was providing for templates and configs file were wrong.
After that it get solved…
hello, i am having a problem with smarty.. i’ve followed the steps but when i run the directory, there’s only a blank page it doesn’t display anything at all.. please help i really need this.. thanks.
hehehe… i made it run already.. yahooooo!
the reason is that i placed the folder in a wrong directory.. funny.
Thanks for your Help
i am using a wampserver2.0 and i want to install smarty in the wampserver.can anybody help me how can i do that?
Fantastic – worked perfectly – thanks!
i am try to install smarty but the below erro show in my browser
Parse error: syntax error, unexpected T_CLASS in C:\wamp\www\myjob\index.php on line 4
hi sakthi i think its same error you get which semicolon and where you put that is in ini file or index file
September 27, 2007 at 2:37 am
hmm, why can’t i do that? i do exact things like you wrote, but it’s still not working…