Page 1 of 1

Can I install Smarty on XAMPP and, if so, how?

PostPosted: 26. July 2004 12:48
by shekinah
I've successfully installed XAMPP on my desktop machine running Windows XP Pro as I am learning php and mySQL and want to test things before loading to the server.
I would like to use/test Smarty but do not want to do anything that might stop XAMPP working properly.
Does anyone have any experience of successfully setting up Smarty with XAMPP?

I have the Smarty PDF manual but I want to make sure I edit the right php.ini and that I do so correctly. I think I need the one in c:\apachefriends\xampp\apache\bin\php.ini rather than c:\apachefriends\xampp\php\php.ini as indicated by another post on the list but would rather take advice from someone who has done this succesfully than start experimenting with a currently stable XAMPP setup.

The manual instructions are as follows:
Install the Smarty library files which are in the /libs/ directory of the distribution. These are the PHP files that you SHOULD NOT edit. They are shared among all applications and they only get updated when you upgrade to a new version of Smarty.

Example 2-1. Smarty library files
/core/*.php (all of them)
/plugins/*.php (all of them)

Smarty uses a PHP constant named SMARTY_DIR which is the system filepath Smarty library directory. Basically, if your application can find the Smarty.class.php file, you do not need to set SMARTY_DIR, Smarty will figure it out on its own.

Therefore, if Smarty.class.php is not in your include_path, or you do not supply an absolute path to it in your application, then you must define SMARTY_DIR manually. SMARTY_DIR must include a trailing slash.
Here is how you create an instance of Smarty in your PHP scripts:

Example 2-2. Create Smarty instance of Smarty
$smarty = new Smarty;
Try running the above script. If you get an error saying the Smarty.class.php file could
not be found, you have to do one of the following:

Example 2-3. Supply absolute path to library file
$smarty = new Smarty;

Example 2-4. Add library directory to php_include path
// Edit your php.ini file, add the Smarty library
// directory to the include_path and restart web server.
// Then the following should work:
$smarty = new Smarty;

Example 2-5. Set SMARTY_DIR constant manually
$smarty = new Smarty;