O'Reilly logo

Learning PHP, MySQL, and JavaScript by Robin Nixon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Installation

To install Smarty, visit http://www.smarty.net/download.php and download the latest ZIP archive. Once it’s downloaded, you need to perform the following steps:

  1. Extract the contents of the downloaded file into a suitable folder.

  2. Determine your web server document’s root by running the following PHP snippet (if you don’t already know it):

    <?php echo $_SERVER['DOCUMENT_ROOT']; ?>
  3. Create a new folder called Smarty in this document root.

  4. Open the extracted folder, navigate into the libs directory, and copy the entire contents (including subfolders) into the Smarty directory you just created. You will end up with the following directory structure in your document root:

    Smarty
        internals
            (various files...)
        plugins
            (various files...)
        Config_File.class.php
        debug.tpl
        Smarty.class.php
        Smarty_Compiler.class.php

That gets Smarty installed, but you also need to create four subdirectories for every application that uses it. So create the new application directory temp just under the same document root where you just installed Smarty. This will hold the files for a temporary application that we’ll write to test Smarty.

Inside the temp directory, create another one called smarty to house the folders containing the template files. Finally, create the following subdirectories within the new smarty directory: cache, configs, templates, and templates_c. Your directory structure is now:

temp
    smarty
        cache
        configs
        templates
        templates_c

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required