static function assertEnvironmentIsOk()
{
# Asserting Baikal Context
if (!defined("BAIKAL_CONTEXT") || BAIKAL_CONTEXT !== true) {
die("Bootstrap.php may not be included outside the Baikal context");
}
# Asserting PDO
if (!defined('PDO::ATTR_DRIVER_NAME')) {
die('Baikal Fatal Error: PDO is unavailable. It\'s required by Baikal.');
}
# Asserting PDO::SQLite or PDO::MySQL
$aPDODrivers = \PDO::getAvailableDrivers();
if (!in_array('sqlite', $aPDODrivers) && !in_array('mysql', $aPDODrivers)) {
die('<strong>Baikal Fatal Error</strong>: Both <strong>PDO::sqlite</strong> and <strong>PDO::mysql</strong> are unavailable. One of them at least is required by Baikal.');
}
}
public static function bootstrap() { # Registering Baikal classloader define("BAIKAL_PATH_FRAMEWORKROOT", dirname(__FILE__) . "/"); \Baikal\Core\Tools::assertEnvironmentIsOk(); \Baikal\Core\Tools::configureEnvironment(); # Check that a config file exists if (!file_exists(PROJECT_PATH_SPECIFIC . "config.php") || !file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) { self::installTool(); } else { require_once PROJECT_PATH_SPECIFIC . "config.php"; require_once PROJECT_PATH_SPECIFIC . "config.system.php"; date_default_timezone_set(PROJECT_TIMEZONE); # Check that Baïkal is already configured if (!defined("BAIKAL_CONFIGURED_VERSION")) { self::installTool(); } else { # Check that running version matches configured version if (version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) { self::installTool(); } else { # Check that admin password is set if (!defined("BAIKAL_ADMIN_PASSWORDHASH")) { self::installTool(); } \Baikal\Core\Tools::assertBaikalIsOk(); set_error_handler("\\Baikal\\Framework::exception_error_handler"); } } } }