/** * Returns a singleton instance of Zend_Cache, or null if the cache is not * available. * * @return Zend_Cache|null */ public static function getInstance() { if (self::$_instance === null) { try { $config = Zend_Registry::get('config'); self::$_instance = Zend_Cache::factory('Core', 'Memcached', array('lifetime' => 300, 'automatic_serialization' => true), array('servers' => array(array('host' => $config->cache->host, 'port' => $config->cache->port)))); } catch (Zend_Cache_Exception $e) { } } return self::$_instance; }
<?php include_once '../bootstrap.php'; Zend_Layout::startMvc(); $cache = Yadda_Cache::getInstance(); if ($cache !== null) { Zend_Session::setSaveHandler(new Yadda_Session_SaveHandler($cache)); } $front = Zend_Controller_Front::getInstance(); $front->setControllerDirectory(array('www' => APPLICATION_BASE . '/modules/www/controllers'))->setDefaultModule('www')->setRouter(new Www_Controller_Router())->dispatch();
if (isset($test['e'])) { $env = $test['e']; } } define('APPLICATION_ENVIRONMENT', $env); // errors if (APPLICATION_ENVIRONMENT == 'development' || defined('STDIN')) { ini_set('display_errors', '1'); error_reporting(E_ALL); } else { ini_set('display_errors', '0'); error_reporting(E_ERROR); } // defaults date_default_timezone_set('Africa/Johannesburg'); define('APPLICATION_BASE', dirname(__FILE__)); set_include_path(APPLICATION_BASE . '/lib'); // autoloader require_once 'Zend/Loader/Autoloader.php'; $loader = Zend_Loader_Autoloader::getInstance(); $loader->registerNamespace('Yadda_'); $loader->registerNamespace('Www_'); $loader->registerNamespace('M_'); $loader->registerNamespace('Data_'); $loader->registerNamespace('Admin_'); // config $config = new Zend_Config_Ini(APPLICATION_BASE . '/config.ini', APPLICATION_ENVIRONMENT); Zend_Registry::set('config', $config); if (($cache = Yadda_Cache::getInstance()) !== null) { Zend_Db_Table::setDefaultMetadataCache($cache); }