I have XAMPP installed and configured. I'm trying to install Smarty 3.1.18
and I'm running into a bit of an issue.
I've changed my php.ini
file to add the smarty/libs directory to the includes. I've unzipped smarty into my c:\smarty
folder I made my smarty\templates
and config
folders in the htdocs folder I've also made my cache and templates_c
folders inside the c:\smarty
folder. I made my index.php
file to include all the directories and made my index.tpl
file and placed that in my templates folder. When I run the index.php
file I return this:
Fatal error: Uncaught --> Smarty: Unable to load template file 'index.tpl' <-- thrown in C:\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
Any ideas??
I have run the testinstall()
script and this is what it returns :
Smarty Installation test...
Testing template directory...
FAILED: .\templates\ does not exist.
Testing compile directory...
FAILED: .\templates_c\ does not exist.
Testing plugins directory...
C:\smarty\libs\plugins is OK.
Testing cache directory...
FAILED: .\cache\ does not exist.
Testing configs directory...
FAILED: .\configs\ does not exist.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
I've checked and rechecked my file locations and directory locations and this is where they are:
$smarty->template_dir = 'c:/xampp/htdocs/smarty/templates';
$smarty->config_dir = ' c:/xampp/htdocs/smarty/config';
$smarty->cache_dir = 'c:/smarty/cache';
$smarty->compile_dir = 'c:/smarty/templates_c';
What you should do is setting correct path to templates, templates_c, cache and config using below methods:
$smarty->setTemplateDir('full_xampp_project_path/templates');
$smarty->setCompileDir('c:\smarty\templates_c');
$smarty->setConfigDir('full_xampp_project_path/config');
$smarty->setCacheDir('c:\smarty\cache');
As full_xampp_project_path
you should provide full path where your project exists for example c:/xampp/htdocs/yourproject
As you unzipped smarty in c:\smarty
and have your project in for example c:/xampp/htdocs/yourproject` you need to set those directories manually.
You should make sure all your paths really exist.
EDIT
I've just tested similar configuration but haven't change anything in php.ini because it's in fact unnecessary. I put Smarty into c:\smarty
and created there templates_c
anc cache
directories, I have also templates
and configs
directory inside directory of my web server.
I use the following code:
<?php
require 'c:\smarty\Smarty.class.php';
$smarty = new Smarty;
$smarty->setTemplateDir('D:\DaneAplikacji\WampServer\www\smarty\demo\templates');
$smarty->setCompileDir('C:\smarty\templates_c');
$smarty->setConfigDir('D:\DaneAplikacji\WampServer\www\smarty\demo\configs');
$smarty->setCacheDir('C:\smarty\cache');
$smarty->testInstall();
$smarty->display('demo.tpl');
And everything works fine. Output is:
Smarty Installation test...
Testing template directory...
D:\DaneAplikacji\WampServer\www\smarty\demo\templates is OK.
Testing compile directory...
C:\smarty\templates_c is OK.
Testing plugins directory...
C:\smarty\plugins is OK.
Testing cache directory...
C:\smarty\cache is OK.
Testing configs directory...
D:\DaneAplikacji\WampServer\www\smarty\demo\configs is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
demo
so everything works as it should. You should simple use methods I described above to set directories and make sure those directories exist.