Installing smarty in Windows (official solution)

Source: Internet
Author: User
Tags phpinfo

From: http://www.smarty.net/quick_start.php => http://news.php.net/php.smarty.dev/2703

 

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 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/configs ';
$ 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.