/** *@return \Framework\Application */ public static function getInstance() { if (self::$_instance == null) { self::$_instance = new \Framework\Application(); } return self::$_instance; }
/** * Application constructor. * @param $config */ function __construct($config) { self::$config = (include $config); /** * output the error message depending on mode */ if (self::$config['mode'] === 'dev') { ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); } else { if (self::$config['mode'] === 'prod') { ini_set('display_errors', 0); ini_set('display_startup_errors', 0); } } /** * start needles services */ Service::get('session')->startSession(); Service::get('router')->addRoutes(self::$config['routes']); Service::get('config')->setConfig(self::$config); Service::get('db')->getConnection(self::$config['pdo']); // initialize connection to DB }
/** * Constructor * * @param string $file */ public function __construct($file) { if (file_exists($file) && is_readable($file)) { $this->_config = (include $file); } else { die('ERROR: Config file not found ' . $file); } $this->setDB(); Service::set('config', $this->_config); Service::set('session', new Session()); Service::set('security', new Security()); Service::set('request', new Request()); Service::set('app', $this); self::$app = $this; }
public function __construct($configPath) { self::$config = (include $configPath); Service::set('request', 'Framework\\Request\\Request'); Service::set('router', function () { $object = new Router(self::$config['routes']); return $object; }); /* Service::set('response', 'Framework\Response\Response'); Service::set('security', 'Framework\Security\Security'); Service::set('session', 'Framework\Session\SessionManager'); Service::set('localization', 'Framework\Localization\LocalizationManager', array(self::$config['localization'])); */ }
/** * Конструктор фронт контроллера * @param $config_path string к конфигурационному файлу */ public function __construct($config_path) { $config = (include_once $config_path); $run_mode = $config["mode"]; self::$logger = Logger::getLogger($this->configureLogParams($run_mode, $config["log"])); Service::set("logger", self::$logger); self::$logger->debug("Run mode set to " . $run_mode); $this->setErrorReportingLevel($run_mode); $this->router = new Router($config["routes"]); $this->pdo = Database::getInstance($config["pdo"]); Service::setAll($config["di"]); Service::set("router", $this->router); Service::set("pdo", $this->pdo->getConnection()); Service::set("config", $config); $this->config = $config; //TODO добавить обработку остальных параметров конфига, когда понядобятся }
<?php @session_start(); defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'); define("FRAMEWORK_PATH", "C:/Documents and Settings/Pieter/Zend/workspaces/DefaultWorkspace7/framwork/"); set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), FRAMEWORK_PATH, get_include_path()))); include_once "Framework/FrameworkApplication.class.php"; //include //include_once "/application/bootstrap.php"; $framework = new FrameworkApplication(); //$framework->setBootstrap(new Bootstrap()); $framework->run();
public function __construct(array $values = []) { parent::__construct($values); self::$_instance = $this; }
public static function loadConfig() { require_once '../app/config.php'; self::$config = $config; }
/** * Application constructor. * @param array $config_path */ public function __construct($config_path = array()) { //override protection self::$config_map = $config_path; Service::get('session'); }