private function __construct() { set_exception_handler([$this, '_exceptionHandler']); Autoloader::registerNamespace('Framework', dirname(__FILE__) . DIRECTORY_SEPARATOR); Autoloader::registerAutoLoad(); $this->_config = Config::getInstance(); }
protected function __construct() { // Add Namespace, for autoloading class with name "Swift" ... Autoloader::addNamespace('Swift', PATH_VENDORS . DS . 'SwiftMailer' . DS); //Load in dependency maps $this->_loadDependencyMaps(); //Load in global library preferences $this->_preferences(); }
public function stop() { if ($this->_isInit && $this->_isRun) { // run caches gc $caches = Cache::getCaches(); foreach ($caches as $cache) { $cache->runGc(); } //profiling if (self::getProfiler()) { // Caches foreach ($caches as $cache) { Logger::getInstance()->debug('Adaptater : "' . get_class($cache) . '"', 'cache' . $cache->getName()); } // Databases $databases = Database::getDatabases(); foreach ($databases as $database) { Logger::getInstance()->debug('Type : ' . $database->getType(), 'database' . $database->getName()); Logger::getInstance()->debug('Adaptater : ' . get_class($database->getAdaptater()), 'database' . $database->getName()); $stats = $database->getStats(); Logger::getInstance()->debug('Queries : ' . (string) $database->getQueryCount() . ' (Aproximately memory used : ' . $stats['ram'] . ' KB in aproximately ' . $stats['time'] . ' ms)', 'database' . $database->getName()); Logger::getInstance()->debug('Servers : ' . $database->countServers() . ' (Masters : ' . $database->countServers(Server::TYPE_MASTER) . ' Slaves : ' . $database->countServers(Server::TYPE_SLAVE) . ')', 'database' . $database->getName()); } // Templates $templates = Template::getTemplates(); foreach ($templates as $template) { Logger::getInstance()->debug('Adaptater : ' . get_class($template), 'template' . $template->getName()); } // Language Logger::getInstance()->debug('Language default is : "' . Language::getInstance()->getDefaultLanguage() . '"', 'language'); Logger::getInstance()->debug(Language::getInstance()->countVars() . ' vars defined', 'language'); // Router Logger::getInstance()->debug('Current url : ' . Http::getCurrentUrl(), 'router'); Logger::getInstance()->debug('Current route : ' . Router::getInstance()->getCurrentRoute(), 'router'); Logger::getInstance()->debug('Current route rule : ' . Router::getInstance()->getCurrentRule(), 'router'); Logger::getInstance()->debug('Ajax request : ' . (int) Http::isAjax(), 'router'); Logger::getInstance()->debug('Ssl request : ' . (int) Http::isHttps(), 'router'); Logger::getInstance()->debug('Request dispatched in aproximately : ' . Benchmark::getInstance('router')->stopTime()->getStatsTime() . ' ms', 'router'); Logger::getInstance()->debug('Aproximately memory used : ' . Benchmark::getInstance('router')->stopRam()->getStatsRam() . ' KB', 'router'); // Logger debug informations and benchmark Logger::getInstance()->addGroup('logger', 'Logger Benchmark and Informations', true); Logger::getInstance()->debug(Logger::getInstance()->countObservers() . ' observers registered', 'logger'); Logger::getInstance()->debug(Logger::getInstance()->countGroups() . ' groups and ' . (Logger::getInstance()->countLogs() + 3) . ' logs', 'logger'); Logger::getInstance()->debug('In aproximately ' . Benchmark::getInstance('logger')->stopTime()->getStatsTime() . ' ms', 'logger'); Logger::getInstance()->debug('Aproximately memory used : ' . Benchmark::getInstance('logger')->stopRam()->getStatsRam() . ' KB', 'logger'); // Autoloader Logger::getInstance()->addGroup('autoloader', 'Autoloader report', true); $logs = Autoloader::getLogs(); foreach ($logs as &$log) { Logger::getInstance()->debug($log, 'autoloader'); } Logger::getInstance()->debug(count(Autoloader::getAutoloaders()) . ' autoloader adaptaters, ' . count(Autoloader::getDirectories()) . ' directories and ' . count(Autoloader::getNamespaces()) . ' namespaces registered', 'autoloader'); Logger::getInstance()->debug('Loading ' . count(Autoloader::getClasses()) . ' classes (' . Autoloader::countGlobalizedClasses() . ' globalized classes) in aproximately ' . round(Autoloader::getBenchmark('time') * 1000, 4) . ' ms', 'autoloader'); Logger::getInstance()->debug('Aproximately memory used : ' . round(Autoloader::getBenchmark('memory') / 1024, 4) . ' KB', 'autoloader'); Autoloader::purgeLogs(); Autoloader::purgeBenchmark(); // Global informations && Benchmark Logger::getInstance()->addGroup('global', 'Global Benchmark and Informations', true); Logger::getInstance()->debug('Page generated in aproximately : ' . Benchmark::getInstance('global')->stopTime()->getStatsTime() . ' ms', 'global'); Logger::getInstance()->debug('Aproximately memory used : ' . Benchmark::getInstance('global')->stopRam()->getStatsRam() . ' KB - Memory allocated : ' . memory_get_peak_usage(true) / 1024 . ' KB', 'global'); } //notify logger Logger::getInstance()->notify(); // Stop managers ExceptionManager::getInstance()->stop(); ErrorManager::getInstance()->stop(); // avoid multi call $this->_isInit = false; $this->_isRun = false; } }
/** * Include necessary files, and setting class autoloader * * @copyright Copyright 2014 - MidichlorianPHP and contributors * @author NAYRAND Jérémie (dreadlokeur) <*****@*****.**> * @version 1.0.1dev2 * @license GNU General Public License 3 http://www.gnu.org/licenses/gpl.html * @package MidichloriansPHP */ use framework\Autoloader; // Checking if (!version_compare(PHP_VERSION, '5.4.0', '>=')) { throw new \Exception('You must have at least PHP 5.4.0'); } // Include neccesary files require_once 'paths.php'; require_once PATH_FRAMEWORK . 'autoloader' . DS . 'Classes.trait.php'; require_once PATH_FRAMEWORK . 'autoloader' . DS . 'Directories.trait.php'; require_once PATH_FRAMEWORK . 'autoloader' . DS . 'Namespaces.trait.php'; require_once PATH_FRAMEWORK . 'Autoloader.class.php'; // Autoloader configuration $autoloader = new Autoloader(); $autoloader->setAutoloadExtensions(array('class.php', 'abstract.php', 'final.php', 'interface.php', 'trait.php', 'php')); $autoloader->addNamespaces(array('framework' => PATH_FRAMEWORK, 'libs' => PATH_LIBS, 'controllers' => PATH_CONTROLLERS, 'models' => PATH_MODELS)); // Include autoloaders adaptaters require_once PATH_FRAMEWORK . 'autoloader' . DS . 'IAdaptater.interface.php'; require_once PATH_FRAMEWORK . 'autoloader' . DS . 'adaptaters' . DS . 'Finder.class.php'; require_once PATH_FRAMEWORK . 'autoloader' . DS . 'adaptaters' . DS . 'Cache.class.php'; require_once PATH_FRAMEWORK . 'autoloader' . DS . 'adaptaters' . DS . 'Includer.class.php'; $autoloader->registerAutoloaders(array('Finder', 'Cache', 'Includer'));
throw new \Exception('Miss language path datas'); } Language::setDatasPath(PATH_LANGUAGE); $language = Language::getInstance(); if (!defined('LANGUAGE_DEFAULT')) { throw new \Exception('Miss language default'); } $language->setLanguage(LANGUAGE_DEFAULT, true, true); // Set default template if (defined('TEMPLATE_DEFAULT')) { Template::setTemplate(TEMPLATE_DEFAULT); } //Enable debug tools if (static::getDebug()) { $log->setLevel(Logger::DEBUG); Autoloader::setDebug(true); //Debug error and exeception $exc->attach(new Display()); $err->attach(new Display()); } // Logger parameters if (defined('LOGGER_CACHE') && LOGGER_CACHE && !static::getDebug()) { $log->setCache(LOGGER_CACHE); } if (defined('LOGGER_LEVEL') && !static::getDebug()) { $log->setLevel(LOGGER_LEVEL); } if (defined('LOGGER_BACKTRACE') && LOGGER_BACKTRACE) { $log->setLogBackTrace(LOGGER_BACKTRACE); } if (defined('LOGGER_WRITE') && LOGGER_WRITE && !static::getDebug()) {
<?php use Framework\HttpContext\HttpContext; date_default_timezone_set('Europe/Sofia'); ini_set('display_errors', 1); session_start(); require_once 'Autoloader.php'; \Framework\Autoloader::init(); HttpContext::setInstance(new Framework\HttpContext\HttpRequest(), new Framework\HttpContext\HttpCookie(), new Framework\HttpContext\HttpSession(), new \Framework\HttpContext\HttpUser()); //\Framework\HttpContext\HttpContext::getInstance()->getCookies()->time->delete(); // //$date = new DateTime('now', new DateTimeZone('Europe/Sofia')); //\Framework\HttpContext\HttpContext::getInstance()->getCookies()->time = $date->format("Y-m-d H:i:s"); // //echo "Time cookie " . \Framework\HttpContext\HttpContext::getInstance()->getCookies()->time . " END"; //var_dump($_COOKIE); // //\Framework\HttpContext\HttpContext::getInstance()->getCookies()->time->delete(); // //var_dump($_COOKIE); // //exit; //\Framework\HttpContext\HttpContext::getInstance()->getSession()->time->delete(); // //var_dump($_SESSION); // //$date = new DateTime('now', new DateTimeZone('Europe/Sofia')); //\Framework\HttpContext\HttpContext::getInstance()->getSession()->time = $date->format("Y-m-d H:i:s"); // //echo "Time session " . \Framework\HttpContext\HttpContext::getInstance()->getSession()->time . " END"; //var_dump($_SESSION);