/** * @param array $server * @param $tmpPath * @param string $logging */ private static function setupUtils(array $server, $tmpPath, $logging = 'file') { self::$env = new Environment($server); $envData = self::$env->data(); Logger::setup(self::$env->getIp(), $envData->get('PHP_SELF', $envData->get('SCRIPT_NAME'))); ResponseStatus::setup($envData->get('SERVER_PROTOCOL', 'HTTP/1.0')); Header::setup(self::$env->getUserAgent()); Url::setup(self::$env->getUrl(), self::$env->isHttps()); Uri::setup(self::$env->PATH_INFO, self::$env->REQUEST_URI); Uuid::setup(self::$env->getIp(), self::$env->getHost()); if ($logging === 'file') { self::$logger = new Logger(new Adapter\File($tmpPath, "pimf-logs.txt"), new Adapter\File($tmpPath, "pimf-warnings.txt"), new Adapter\File($tmpPath, "pimf-errors.txt")); } else { self::$logger = new Logger(new Adapter\Std(Adapter\Std::OUT), new Adapter\Std(Adapter\Std::OUT), new Adapter\Std(Adapter\Std::ERR)); } self::$logger->init(); }
<?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);