示例#1
0
 public static function getConfig($name, $environment = null)
 {
     static $currentEnvironment, $baseEnvironment;
     profiler::addStack('config::get');
     if ($currentEnvironment === null) {
         $currentEnvironment = environment::getCurrentEnvironment();
         MPCMF_LL_DEBUG && error_log("Initialize config current environment: {$currentEnvironment}");
     }
     if ($baseEnvironment === null) {
         $baseEnvironment = environment::getBaseEnvironment();
         MPCMF_LL_DEBUG && error_log("Initialize config base environment: {$baseEnvironment}");
     }
     if ($environment === null) {
         $environment = $currentEnvironment;
     }
     MPCMF_LL_DEBUG && error_log("Input environment: {$environment}");
     $packageName = self::getPackageName($name);
     class_exists('log') && log::factory()->addDebug("Loading config for {$packageName}");
     if (!isset(self::$loaded[$packageName])) {
         self::loadPackageConfig($packageName);
     }
     class_exists('log') && log::factory()->addDebug("Set by name: {$name} / env: {$environment}");
     if ($environment !== environment::ENV_DEFAULT) {
         if (isset(self::$loaded[$packageName][$currentEnvironment])) {
             MPCMF_LL_DEBUG && error_log("Return requested config [{$packageName}] {$currentEnvironment}");
             return self::$loaded[$packageName][$currentEnvironment];
         } elseif ($baseEnvironment !== environment::ENV_DEFAULT && isset(self::$loaded[$packageName][$baseEnvironment])) {
             MPCMF_LL_DEBUG && error_log("Use base config [{$packageName}] {$baseEnvironment}");
             return self::$loaded[$packageName][$baseEnvironment];
         } else {
             MPCMF_LL_DEBUG && error_log("Return default config [{$packageName}] {$currentEnvironment}");
             return self::$loaded[$packageName][environment::ENV_DEFAULT];
         }
     }
     MPCMF_LL_DEBUG && error_log("Return config [{$packageName}] " . environment::ENV_DEFAULT);
     return self::$loaded[$packageName][environment::ENV_DEFAULT];
 }
示例#2
0
文件: log.php 项目: mpcmf/mpcmf-core
 /**
  * @return monologWrapper
  */
 protected static function log()
 {
     return monologWrapper::factory();
 }
示例#3
0
<?php

namespace mpcmf;

use mpcmf\system\io\log;
!defined('APP_ROOT') && define('APP_ROOT', __DIR__);
!defined('APP_NAME') && define('APP_NAME', 'mpcmf');
$GLOBALS['MPCMF_START_TIME'] = microtime(true);
require_once APP_ROOT . '/vendor/autoload.php';
require_once APP_ROOT . '/environment.php';
MPCMF_DEBUG && log::factory()->addDebug('Base project directory: ' . APP_ROOT);