// plugins $path = APP_PATH . "/application/plugins"; $iterator = new DirectoryIterator($path); foreach ($iterator as $item) { if (!$item->isDot() && $item->isDir()) { include $path . "/" . $item->getFilename() . "/initialize.php"; } } // 3. load and initialize the Configuration class $configuration = new Framework\Configuration(array("type" => "ini")); Framework\Registry::set("configuration", $configuration->initialize()); // 4. load and initialize the Database class – does not connect $database = new Framework\Database(); Framework\Registry::set("database", $database->initialize()); // 5. load and initialize the Cache class – does not connect $cache = new Framework\Cache(); Framework\Registry::set("cache", $cache->initialize()); // 6. load and initialize the Session class $session = new Framework\Session(); Framework\Registry::set("session", $session->initialize()); // 7. load the Router class and provide the url + extension $router = new Framework\Router(array("url" => isset($_GET["url"]) ? $_GET["url"] : "home/index", "extension" => !empty($_GET["extension"]) ? $_GET["extension"] : "html")); Framework\Registry::set("router", $router); // include custom routes include "public/routes.php"; // 8. dispatch the current request $router->dispatch(); // 9. unset global variables unset($configuration); unset($database); unset($cache);
protected function mongod() { $mongod = Registry::get("mongod"); if ($mongod) { return $mongod; } else { $cache = new \Framework\Cache(array("type" => "mongod")); $m = $cache->initialize(); $m->connect('healthlitmus'); Registry::set("mongod", $m); return $m; } }
<?php require_once 'autoloader.php'; try { $cache = new Framework\Cache(array("type" => "memcached")); $driver = $cache->initialize(); $driver->connect(); $driver->set('test', '12345'); echo $driver->get('test'); } catch (Exception $e) { echo $e->getMessage(); }