Smarty Konfiguration

Ich bin es nicht zufrieden, meine Smarty-Konfiguration auf eine der beiden vorgeschlagenen Arten zu erledigen. Viel zu aufwendig!

Bessere Lösung

setup.php kommt in den cfg-Ordner im Projekt-smarty-Verzeichnis. Kann man einfach so belassen und weiterkopieren für das nächste Projekt, Pfade passen sich an. Gern geschehen.

/smarty/setup.php
 # ----------------------------------------------------------------------------
 # PRJ_ROOT/smarty/cfg/smarty.php - the SMARTY cfg w/the least changes
 # Created: 19.09.2018 17:12:19Z by pieli
 # Updated: 19.09.2018 17:12:19Z by pieli
 # ----------------------------------------------------------------------------
 # defines: configure your project here!
 # ----------------------------------------------------------------------------
 define('SYSTEM',    'default'); // what system are you on?
 define('SMARTY_VER','3.1.32');  // what smarty ver will you pick?
 define('SMARTY_DIR','/var/php/smarty/smarty-' . SMARTY_VER . '/libs/');
 
 # ----------------------------------------------------------------------------
 # no need for changes beyond this point!
 # ----------------------------------------------------------------------------
 
 # ----------------------------------------------------------------------------
 # find out path for project
 # ----------------------------------------------------------------------------
 $trenners = array('default' => '/','windows' => '\\');
 $segments = explode($trenners[SYSTEM],__FILE__);
 array_pop($segments);
 array_pop($segments);
 array_pop($segments);
 define('PRJ_ROOT',implode($trenners['default'],$segments));
 
 # ----------------------------------------------------------------------------
 # house keep, only CONSTANTS will survive
 # ----------------------------------------------------------------------------
 unset($segments);
 unset($trenners);
 
 # ----------------------------------------------------------------------------
 # load SMARTY library
 # ----------------------------------------------------------------------------
 require_once(SMARTY_DIR . 'Smarty.class.php');
 $smarty = new Smarty;
 
 # ----------------------------------------------------------------------------
 # set SMARTY defaults
 # ----------------------------------------------------------------------------
 $smarty->setTemplateDir( PRJ_ROOT . '/smarty/templates/' );
 $smarty->setCompileDir( PRJ_ROOT . '/smarty/templates_c/' );
 $smarty->setConfigDir( PRJ_ROOT . '/smarty/cfg/' );
 $smarty->setCacheDir( PRJ_ROOT . '/smarty/cache/' );
 
 # ----------------------------------------------------------------------------
 # after requiring this, smarty is loaded, configured and good to go!
 # ----------------------------------------------------------------------------