public function __construct() { parent::__construct(); /** * @var TigerView $view */ $view = $this->slim->view(); $view->setSiteTitle(TigerApp::Config("Application Name")); $view->addCSS("vendor/twbs/bootstrap/dist/css/bootstrap.min.css"); $view->addCSS("assets/css/navbar.css"); }
/** * @return TigerApp */ public function begin() { if (defined('APP_ENV')) { $configFile = APP_ENV . '.yaml'; } elseif (getenv('HOST')) { $configFile = getenv('HOST') . '.yaml'; } else { $configFile = 'Default.yaml'; } $this->parseConfig("{$this->appRoot}/config/{$configFile}"); $this->logger = $this->setupLogger(); if ($this->config['Debug Mode'] == "On") { error_reporting(E_ALL); ini_set("display_errors", 1); } $environment = array_merge($_ENV, $_SERVER); ksort($environment); // TODO: Load app tree from yaml $this->appTree = self::$defaultAppTree; // Initialise databases if (count(TigerApp::Config("Databases")) > 0) { foreach (TigerApp::Config("Databases") as $name => $settings) { $config = array(); $config['db_type'] = $settings['Type']; if (isset($settings['DockerLink'])) { $prefix = strtoupper($settings['DockerLink']); if (isset($environment["{$prefix}_PORT"])) { $host = parse_url($environment["{$prefix}_PORT"]); $config['db_hostname'] = $host['host']; $config['db_port'] = $host['port']; if (isset($environment["{$prefix}_USERNAME"])) { $config['db_username'] = $environment["{$prefix}_USERNAME"]; } if (isset($environment["{$prefix}_ENV_MYSQL_USER"])) { $config['db_username'] = $environment["{$prefix}_ENV_MYSQL_USER"]; } if (isset($environment["{$prefix}_PASSWORD"])) { $config['db_password'] = $environment["{$prefix}_PASSWORD"]; } if (isset($environment["{$prefix}_ENV_MYSQL_PASSWORD"])) { $config['db_password'] = $environment["{$prefix}_ENV_MYSQL_PASSWORD"]; } if (isset($environment["{$prefix}_DATABASE"])) { $config['db_database'] = $environment["{$prefix}_DATABASE"]; } if (isset($environment["{$prefix}_ENV_MYSQL_DATABASE"])) { $config['db_database'] = $environment["{$prefix}_ENV_MYSQL_DATABASE"]; } } else { throw new \Exception("Cannot find \$environment[{$prefix}_PORT] trying to use DockerLink config."); } } if (isset($settings['Host'])) { $config['db_hostname'] = $settings['Host']; } if (isset($settings['Port'])) { $config['db_port'] = $settings['Port']; } if (isset($settings['Username'])) { $config['db_username'] = $settings['Username']; } if (isset($settings['Password'])) { $config['db_password'] = $settings['Password']; } if (isset($settings['Database'])) { $config['db_database'] = $settings['Database']; } // Sqlite-specific if (isset($settings['File'])) { $config['db_file'] = $settings['File']; } $this->dbPool[$name] = new ActiveRecord\DatabaseLayer($config); } } // Initialise Storage Pool if (TigerApp::Config("Storage") !== false) { foreach (TigerApp::Config("Storage") as $name => $config) { $this->storagePool[$name] = $this->setupStorage($config); } } // Initialise Redis Pool // TODO: Write this. // Initialise Session $this->session = new Session(); // Initialise slim app. $this->slimApp = new TigerSlim(array('templates.path' => self::TemplatesRoot(), 'log.writer' => $this->logger, 'log.enabled' => true)); // Set up whoops //$this->slimApp->config('whoops.editor', 'phpstorm'); //$this->slimApp->add(new WhoopsMiddleware()); // Set the View controller. // TODO: Make this settable in the config or somewhere in the sample App $this->slimApp->view(new TigerView()); // Add routes to slim $this->parseRoutes(); return $this; }
public function testConfigDoesNotExist() { $this->assertFalse(TigerApp::Config('Bogus')); }