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