/** * Mechanism used to do initial setup and edging before a application runs. * * @param array $conf The array of configuration options. * @param array $server Array of information such as headers, paths, and script locations. * * @return boolean|null */ public static function bootstrap(array $conf, array $server = array()) { $problems = array(); try { Config::load($conf); $environment = Config::get('environment'); date_default_timezone_set(Config::get('timezone')); self::setupUtils($server, Config::get('bootstrap.local_temp_directory'), Config::get('logging.storage', 'file')); self::loadListeners(BASE_PATH . 'app/' . Config::get('app.name') . '/events.php'); self::setupErrorHandling($environment); self::loadPdoDriver($environment, Config::get($environment . '.db'), Config::get('app.name')); self::loadRoutes(Config::get('app.routeable'), BASE_PATH . 'app/' . Config::get('app.name') . '/routes.php'); } catch (\Throwable $throwable) { $problems[] = $throwable->getMessage(); } catch (\Exception $exception) { $problems[] = $exception->getMessage(); } self::reportIf($problems, PHP_VERSION); }
<?php /* |-------------------------------------------------------------------------- | PIMF core bootstrap used for unit testing |-------------------------------------------------------------------------- */ if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!defined('BASE_PATH')) { define('BASE_PATH', realpath(__DIR__) . DS); } require_once 'autoload.core.php'; require_once 'utils.php'; \Pimf\Config::load(array('environment' => 'testing', 'timezone' => 'UTC', 'ssl' => false, 'app' => array('name' => 'MyFirstBlog', 'key' => 'some5secret5key5here', 'default_controller' => 'blog', 'routeable' => true, 'restfull' => false, 'url' => 'http://localhost', 'index' => '', 'asset_url' => ''), 'production' => array('db' => array('driver' => 'sqlite', 'database' => 'app/MyFirstBlog/_database/blog-production.db')), 'testing' => array('db' => array('driver' => 'sqlite', 'database' => 'app/MyFirstBlog/_database/blog-production.db')), 'bootstrap' => array('local_temp_directory' => '/tmp/'), 'error' => array('ignore_levels' => array(0), 'debug_info' => true, 'log' => true), 'logging' => array('storage' => 'file'), 'session' => array('storage' => 'memory', 'storage_path' => 'app/MyFirstBlog/_session/', 'database' => array('driver' => 'sqlite', 'database' => 'app/MyFirstBlog/_session/blog-session.db'), 'garbage_collection' => array(2, 100), 'lifetime' => 60, 'expire_on_close' => false, 'cookie' => 'pimf_session', 'path' => '/', 'domain' => null, 'secure' => false), 'cache' => array('storage' => 'memory', 'storage_path' => 'app/MyFirstBlog/_cache/', 'database' => array('driver' => 'sqlite', 'database' => 'app/MyFirstBlog/_cache/blog-cache.db'), 'key' => 'pimfmaster', 'memcached' => array('servers' => array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100))))); $env = new \Pimf\Environment($_SERVER); $envData = $env->data(); \Pimf\Logger::setup($env->getIp(), $envData->get('PHP_SELF', $envData->get('SCRIPT_NAME'))); \Pimf\Util\Header\ResponseStatus::setup($envData->get('SERVER_PROTOCOL', 'HTTP/1.0')); \Pimf\Util\Header::setup($env->getUserAgent()); \Pimf\Url::setup($env->getUrl(), $env->isHttps()); \Pimf\Uri::setup($env->PATH_INFO, $env->REQUEST_URI); \Pimf\Util\Uuid::setup($env->getIp(), $env->getHost()); unset($env, $envData);