Install smarty on Windows

Source: Internet
Author: User

1. Download the smarty package
You can download: http://smarty.php.net from official site

 

2. decompress the smarty package and find a suitable location for storage. The folder name is smarty. Copy the folder containing the smarty file to a directory.

In the following content, we assume that your file is stored in C:/apache2/include/smarty.

 

3. Find your php. ini configuration file and modify the destde_path option of PHP. ini. Add the path of the smarty library file, for example:
Include_path = "C:/apache2/include/smarty/Libs"

Note: php. ini contains two types of include_path, which are used in UNIX and windows. You need to modify the values used in Windows:
-------------------------------------------------------------
; Windows: "/path1;/path2"
Include_path = "C:/apache2/include/smarty/Libs"

 

4. Create a folder under your website directory with any name. Assume It is smarty:
Then, create four folders, templates, configs, template-C, and cache, under the mysmarty directory.
After the creation is complete:
(Your website directory)/smarty/templates (this directory is used to store templates)
(Your website directory)/smarty/configs (this directory is used to store some configuration information)

(Your website directory)/smarty/templates-C (this directory is used to store compilation files)

(Your website directory)/smarty/cache (this directory is used to store cache)

 

5. At this time, you should not forget to set the permissions for the Four folders we created from the beginning to now.

Open the "Security" tab in "properties" and list the users who can access this directory,

If you do not have the Web access permission, add the Internet Guest Account and the IIS process account. If you are in trouble, you can directly use everyone

Add the user group to allow access by any user.

6. The installation is basically completed at this time. You can test the first simple example:
Create the index. php file under your website directory, and create the index. TPL file under (website directory)/smarty/templates/. Enter the following code respectively.
Index. php
<? PHP
// Load the smarty library. INI sets include_path to C:/apache2/include/smarty/libs, so you can directly use include ("Smarty. class. PHP ");
// If include_path is not set, you can directly copy smarty. Class. php to the website directory without adding an absolute path.
Require ('smarty. Class. php ');

$ Smarty = new smarty;

// The following (your website directory) uses an absolute path, and you can use a relative path (./templates)
$ Smarty-> template_dir = 'e:/site/smarty/templates ';
$ Smarty-> config_dir = 'e:/site/smarty/configs ';
$ Smarty-> cache_dir = 'e:/site/smartycache ';
$ Smarty-> compile_dir = 'e:/site/smarty/templates_c ';
// Required parameter configuration before using smarty for the above four actions

$ Smarty-> assign ('name', 'Tomorrow ');
$ Smarty-> display ('index. TPL ');
?>
Index. TPL
<HTML>
<Body>
Hello, {$ name }!
</Body>
</Html>

 

7. Now you can browse your work. Run index. php

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.