当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::isLive方法代码示例

本文整理汇总了PHP中Environment::isLive方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::isLive方法的具体用法?PHP Environment::isLive怎么用?PHP Environment::isLive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Environment的用法示例。


在下文中一共展示了Environment::isLive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ifClassExists

 /**
  * Throws an deprecated exception if given type exists.
  *
  * If no message is given, an auto-generated message will be used
  * which contains type/method & location where this method has been
  * invoked - respectively the location of the deprecated code.
  *
  * @param string $namespace_
  * @param string $clazz_
  * @param string $message_
  *
  * @throws \Components\Deprecated
  */
 public static function ifClassExists($namespace_, $clazz_, $message_ = null)
 {
     // ignore for production.
     if (Environment::isLive()) {
         return;
     }
     if (false === @class_exists($clazz_)) {
         if (null === $message_) {
             throw static::createDefaultException($namespace_);
         }
         throw new static($namespace_, $message_, null, true);
     }
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.type,代码行数:26,代码来源:deprecated.php

示例2: loadConfig

 /**
  * Loads global configuration from file and process it.
  * @param  string|Nette\Config\Config  file name or Config object
  * @param  bool
  * @return Nette\Config\Config
  */
 public function loadConfig($file, $useCache)
 {
     if ($useCache === NULL) {
         $useCache = Environment::isLive();
     }
     $cache = $useCache && $this->cacheKey ? Environment::getCache('Nette.Environment') : NULL;
     $name = Environment::getName();
     $cacheKey = Environment::expand($this->cacheKey);
     if (isset($cache[$cacheKey])) {
         Environment::swapState($cache[$cacheKey]);
         $config = Environment::getConfig();
     } else {
         if ($file instanceof Config) {
             $config = $file;
             $file = NULL;
         } else {
             if ($file === NULL) {
                 $file = $this->defaultConfigFile;
             }
             $file = Environment::expand($file);
             $config = Config::fromFile($file, $name, 0);
         }
         // process environment variables
         if ($config->variable instanceof Config) {
             foreach ($config->variable as $key => $value) {
                 Environment::setVariable($key, $value);
             }
         }
         if (PATH_SEPARATOR !== ';' && isset($config->set->include_path)) {
             $config->set->include_path = str_replace(';', PATH_SEPARATOR, $config->set->include_path);
         }
         $config->expand();
         $config->setReadOnly();
         // process services
         $locator = Environment::getServiceLocator();
         if ($config->service instanceof Config) {
             foreach ($config->service as $key => $value) {
                 $locator->addService($value, strtr($key, '-', '\\'));
             }
         }
         // save cache
         if ($cache) {
             $state = Environment::swapState(NULL);
             $state[0] = $config;
             // TODO: better!
             $cache->save($cacheKey, $state, array(Cache::FILES => $file));
         }
     }
     // check temporary directory - TODO: discuss
     /*
     $dir = Environment::getVariable('tempDir');
     if ($dir && !(is_dir($dir) && is_writable($dir))) {
     	trigger_error("Temporary directory '$dir' is not writable", E_USER_NOTICE);
     }
     */
     // process ini settings
     if ($config->set instanceof Config) {
         foreach ($config->set as $key => $value) {
             $key = strtr($key, '-', '.');
             if (function_exists('ini_set')) {
                 ini_set($key, $value);
             } else {
                 switch ($key) {
                     case 'include_path':
                         set_include_path($value);
                         break;
                     case 'iconv.internal_encoding':
                         iconv_set_encoding('internal_encoding', $value);
                         break;
                     case 'mbstring.internal_encoding':
                         mb_internal_encoding($value);
                         break;
                     case 'date.timezone':
                         date_default_timezone_set($value);
                         break;
                     case 'error_reporting':
                         error_reporting($value);
                         break;
                     case 'ignore_user_abort':
                         ignore_user_abort($value);
                         break;
                     case 'max_execution_time':
                         set_time_limit($value);
                         break;
                     default:
                         throw new NotSupportedException('Required function ini_set() is disabled.');
                 }
             }
         }
     }
     // define constants
     if ($config->const instanceof Config) {
         foreach ($config->const as $key => $value) {
             define($key, $value);
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:webuntucms,代码行数:101,代码来源:Configurator.php

示例3: enable

 /**
  * Enables displaying or logging errors and exceptions.
  * @param  int   error reporting level
  * @param  bool|string  log to file?
  * @param  array|string  send emails?
  * @return void
  */
 public static function enable($level = E_ALL, $logErrors = NULL, $sendEmails = FALSE)
 {
     if (version_compare(PHP_VERSION, '5.2.1') === 0) {
         throw new NotSupportedException(__METHOD__ . ' is not supported in PHP 5.2.1');
         // PHP bug #40815
     }
     // Environment auto-detection
     if ($logErrors === NULL && class_exists('Environment')) {
         $logErrors = Environment::isLive();
     }
     // Firebug detection
     if (self::$useFirebug === NULL) {
         self::$useFirebug = function_exists('json_encode') && !$logErrors && isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FirePHP/');
     }
     if ($level !== NULL) {
         error_reporting($level);
     }
     if (function_exists('ini_set')) {
         ini_set('display_startup_errors', !$logErrors);
         ini_set('display_errors', !$logErrors);
         // or 'stderr'
         ini_set('html_errors', self::$html);
         ini_set('log_errors', (bool) $logErrors);
     } elseif ($logErrors) {
         // throws error only on production server
         throw new NotSupportedException('Function ini_set() is not enabled.');
     }
     if ($logErrors) {
         if (is_string($logErrors)) {
             self::$logFile = strpos($logErrors, '%') === FALSE ? $logErrors : Environment::expand($logErrors);
         } else {
             try {
                 self::$logFile = Environment::expand('%logDir%/php_error.log');
             } catch (InvalidStateException $e) {
                 self::$logFile = 'php_error.log';
             }
         }
         ini_set('error_log', self::$logFile);
     }
     self::$sendEmails = $logErrors && $sendEmails;
     if (self::$sendEmails) {
         if (is_string($sendEmails)) {
             self::$emailHeaders['To'] = $sendEmails;
         } elseif (is_array($sendEmails)) {
             self::$emailHeaders = $sendEmails + self::$emailHeaders;
         }
         if (mt_rand() / mt_getrandmax() < self::$emailProbability) {
             self::observeErrorLog();
         }
     }
     if (!defined('E_RECOVERABLE_ERROR')) {
         define('E_RECOVERABLE_ERROR', 4096);
     }
     if (!defined('E_DEPRECATED')) {
         define('E_DEPRECATED', 8192);
     }
     set_exception_handler(array(__CLASS__, 'exceptionHandler'));
     set_error_handler(array(__CLASS__, 'errorHandler'));
     self::$enabled = TRUE;
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:67,代码来源:Debug.php


注:本文中的Environment::isLive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。