/** * 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 }
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'])); */ }
public static function loadConfig() { require_once '../app/config.php'; self::$config = $config; }