當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cml\Config類代碼示例

本文整理匯總了PHP中Cml\Config的典型用法代碼示例。如果您正苦於以下問題:PHP Config類的具體用法?PHP Config怎麽用?PHP Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Config類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * 使用的緩存配置 默認為使用default_cache配置的參數
  *
  * @param bool|array $conf
  *
  * @throws PhpExtendNotInstall
  */
 public function __construct($conf = false)
 {
     if (!function_exists('apc_cache_info')) {
         throw new PhpExtendNotInstall(Lang::get('_CACHE_EXTENT_NOT_INSTALL_', 'Apc'));
     }
     $this->conf = $conf ? $conf : Config::get('default_cache');
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:14,代碼來源:Apc.php

示例2: __construct

 public function __construct($conf = false)
 {
     if (!function_exists('apc_cache_info')) {
         \Cml\throwException(Lang::get('_CACHE_EXTENT_NOT_INSTALL_', 'Apc'));
     }
     $this->conf = $conf ? $conf : Config::get('CACHE');
 }
開發者ID:zonquan,項目名稱:cmlphp,代碼行數:7,代碼來源:Apc.php

示例3: appException

 /**
  * 自定義異常處理
  *
  * @param mixed $e 異常對象
  */
 public function appException(&$e)
 {
     $error = [];
     $exceptionClass = new \ReflectionClass($e);
     $error['exception'] = '\\' . $exceptionClass->name;
     $error['message'] = $e->getMessage();
     $trace = $e->getTrace();
     foreach ($trace as $key => $val) {
         $error['files'][$key] = $val;
     }
     if (substr($e->getFile(), -20) !== '\\Tools\\functions.php' || $e->getLine() !== 90) {
         array_unshift($error['files'], ['file' => $e->getFile(), 'line' => $e->getLine(), 'type' => 'throw']);
     }
     if (!Cml::$debug) {
         //正式環境 隻顯示‘係統錯誤’並將錯誤信息記錄到日誌
         Log::emergency($error['message'], [$error['files'][0]]);
         $error = [];
         $error['message'] = Lang::get('_CML_ERROR_');
     }
     if (Request::isCli()) {
         pd($error);
     } else {
         header('HTTP/1.1 500 Internal Server Error');
         View::getEngine('html')->reset()->assign('error', $error);
         Cml::showSystemTemplate(Config::get('html_exception'));
     }
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:32,代碼來源:ErrorOrException.php

示例4: parse

 /**
  * 從注釋解析生成文檔
  *
  */
 public static function parse()
 {
     $result = [];
     $config = Config::load('api', Cml::getApplicationDir('app_controller_path') ? true : false);
     foreach ($config['version'] as $version => $apiList) {
         isset($result[$version]) || ($result[$version] = []);
         foreach ($apiList as $model => $api) {
             $pos = strrpos($api, '\\');
             $controller = substr($api, 0, $pos);
             $action = substr($api, $pos + 1);
             if (class_exists($controller) === false) {
                 continue;
             }
             $annotationParams = self::getAnnotationParams($controller, $action);
             empty($annotationParams) || ($result[$version][$model] = $annotationParams);
         }
     }
     foreach ($result as $key => $val) {
         if (count($val) < 1) {
             unset($result[$key]);
         }
     }
     $systemCode = Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
     Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html', ['config' => $config, 'result' => $result, 'systemCode' => $systemCode]);
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:29,代碼來源:AnnotationToDoc.php

示例5: appException

 /**
  * 自定義異常處理
  *
  * @param mixed $e 異常對象
  */
 public function appException(&$e)
 {
     if (Cml::$debug) {
         $run = new Run();
         $run->pushHandler(Request::isCli() ? new PlainTextHandler() : new PrettyPageHandler());
         $run->handleException($e);
     } else {
         $error = [];
         $error['message'] = $e->getMessage();
         $trace = $e->getTrace();
         $error['files'][0] = $trace[0];
         if (substr($e->getFile(), -20) !== '\\Tools\\functions.php' || $e->getLine() !== 90) {
             array_unshift($error['files'], ['file' => $e->getFile(), 'line' => $e->getLine(), 'type' => 'throw']);
         }
         //正式環境 隻顯示‘係統錯誤’並將錯誤信息記錄到日誌
         Log::emergency($error['message'], [$error['files'][0]]);
         $error = [];
         $error['message'] = Lang::get('_CML_ERROR_');
         if (Request::isCli()) {
             \Cml\pd($error);
         } else {
             header('HTTP/1.1 500 Internal Server Error');
             View::getEngine('html')->reset()->assign('error', $error);
             Cml::showSystemTemplate(Config::get('html_exception'));
         }
     }
     exit;
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:33,代碼來源:Whoops.php

示例6: execute

 /**
  * 創建控製器
  *
  * @param array $args 參數
  * @param array $options 選項
  */
 public function execute(array $args, array $options = [])
 {
     $template = isset($options['template']) ? $options['template'] : false;
     $template || ($template = __DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'Controller.php.dist');
     $name = $args[0];
     $name = explode('-', $name);
     if (count($name) < 2) {
         throw new \InvalidArgumentException(sprintf('The arg name "%s" is invalid. eg: adminbase-Blog/Category', $name));
     }
     $namespace = trim(trim($name[0], '\\/'));
     $path = Cml::getApplicationDir('apps_path') . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . Cml::getApplicationDir('app_controller_path_name') . DIRECTORY_SEPARATOR;
     $component = explode('/', trim(trim($name[1], '/')));
     if (count($component) > 1) {
         $className = ucfirst(array_pop($component)) . Config::get('controller_suffix');
         $component = implode(DIRECTORY_SEPARATOR, $component);
         $path .= $component . DIRECTORY_SEPARATOR;
         $component = '\\' . $component;
     } else {
         $className = ucfirst($component[0]) . Config::get('controller_suffix');
         $component = '';
     }
     if (!is_dir($path) && false == mkdir($path, 0700, true)) {
         throw new \RuntimeException(sprintf('The path "%s" could not be create', $path));
     }
     $contents = strtr(file_get_contents($template), ['$namespace' => $namespace, '$component' => $component, '$className' => $className]);
     if (false === file_put_contents($path . $className . '.php', $contents)) {
         throw new \RuntimeException(sprintf('The file "%s" could not be written to', $path));
     }
     Output::writeln(Colour::colour('Controller created successfully. ', Colour::GREEN));
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:36,代碼來源:Controller.php

示例7: __construct

 /**
  * @param bool $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('CACHE');
     if (extension_loaded('Memcached')) {
         $this->memcache = new \Memcached();
     } elseif (extension_loaded('Memcache')) {
         $this->memcache = new \Memcache();
     } else {
         \Cml\throwException(Lang::get('_CACHE_EXTEND_NOT_INSTALL_', 'Memcache'));
     }
     if (!$this->memcache) {
         \Cml\throwException(Lang::get('_CACHE_NEW_INSTANCE_ERROR_', 'Memcache'));
     }
     if (count($this->conf['server']) > 1) {
         //單台
         if (!$this->memcache->connect($this->conf['host'], $this->conf['port'])) {
             \Cml\throwException(Lang::get('_CACHE_CONNECT_FAIL_', 'Memcache', $this->conf['host'] . ':' . $this->conf['port']));
         }
     } else {
         //多台
         foreach ($this->conf['server'] as $val) {
             $this->memcache->addServer($val['host'], $val['port']);
             //增加服務器
         }
     }
 }
開發者ID:zonquan,項目名稱:cmlphp,代碼行數:29,代碼來源:Memcache.php

示例8: __construct

 /**
  * 使用的緩存配置 默認為使用default_cache配置的參數
  *
  * @param bool|array $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('default_cache');
     if (!extension_loaded('redis')) {
         \Cml\throwException(Lang::get('_CACHE_EXTEND_NOT_INSTALL_', 'Redis'));
     }
 }
開發者ID:hongweipeng,項目名稱:cmlphp,代碼行數:12,代碼來源:Redis.php

示例9: __construct

 /**
  * 使用的緩存配置 默認為使用default_cache配置的參數
  *
  * @param bool|array $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('default_cache');
     if (extension_loaded('Memcached')) {
         $this->memcache = new \Memcached('cml_memcache_pool');
         $this->type = 1;
     } elseif (extension_loaded('Memcache')) {
         $this->memcache = new \Memcache();
         $this->type = 2;
     } else {
         \Cml\throwException(Lang::get('_CACHE_EXTEND_NOT_INSTALL_', 'Memcached/Memcache'));
     }
     if (!$this->memcache) {
         \Cml\throwException(Lang::get('_CACHE_NEW_INSTANCE_ERROR_', 'Memcache'));
     }
     if ($this->type == 2) {
         //memcache
         foreach ($this->conf['server'] as $val) {
             if (!$this->memcache->addServer($val['host'], $val['port'])) {
                 \Cml\throwException(Lang::get('_CACHE_CONNECT_FAIL_', 'Memcache', $this->conf['host'] . ':' . $this->conf['port']));
             }
         }
         return;
     }
     if (md5(json_encode($this->conf['server'])) !== md5(json_encode($this->memcache->getServerList()))) {
         $this->memcache->quit();
         $this->memcache->resetServerList();
         $this->memcache->setOption(\Memcached::OPT_PREFIX_KEY, $this->conf['prefix']);
         \Memcached::HAVE_JSON && $this->memcache->setOption(\Memcached::OPT_SERIALIZER, \Memcached::SERIALIZER_JSON_ARRAY);
         if (!$this->memcache->addServers(array_values($this->conf['server']))) {
             \Cml\throwException(Lang::get('_CACHE_CONNECT_FAIL_', 'Memcache', json_encode($this->conf['server'])));
         }
     }
 }
開發者ID:hongweipeng,項目名稱:cmlphp,代碼行數:39,代碼來源:Memcache.php

示例10: __construct

 /**
  * 使用的緩存配置 默認為使用default_cache配置的參數
  *
  * @param bool |array $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('default_cache');
     if (!extension_loaded('redis')) {
         throw new PhpExtendNotInstall(Lang::get('_CACHE_EXTEND_NOT_INSTALL_', 'Redis'));
     }
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:12,代碼來源:Redis.php

示例11: getLogger

 /**
  * 獲取Logger實例
  *
  * @param string | null $logger 使用的log驅動
  *
  * @return Base
  */
 private static function getLogger($logger = null)
 {
     static $instance = null;
     if (is_null($instance)) {
         $driver = '\\Cml\\Logger\\' . (is_null($logger) ? Config::get('log_driver', 'File') : $logger);
         $instance = new $driver();
     }
     return $instance;
 }
開發者ID:hongweipeng,項目名稱:cmlphp,代碼行數:16,代碼來源:Log.php

示例12: dumpUsePHPConsole

/**
 * 打印數據到chrome控製台
 *
 * @param mixed $var 要打印的變量
 * @param string $tag 標簽
 *
 * @return void
 */
function dumpUsePHPConsole($var, $tag = 'debug')
{
    if (!Config::get('dump_use_php_console')) {
        throwException(Lang::get('_NOT_OPEN_', 'dump_use_php_console'));
    }
    static $connector = false;
    if ($connector === false) {
        $connector = PhpConsoleConnector::getInstance();
        $connector->setPassword(Config::get('php_console_password'));
    }
    $connector->getDebugDispatcher()->dispatchDebug($var, $tag);
}
開發者ID:hongweipeng,項目名稱:cmlphp,代碼行數:20,代碼來源:functions.php

示例13: display

 /**
  * 輸出數據
  *
  */
 public function display()
 {
     header('Content-Type: application/json;charset=' . Config::get('default_charset'));
     if ($GLOBALS['debug']) {
         $sqls = Debug::getSqls();
         if (isset($sqls[0])) {
             $this->args['sql'] = implode($sqls, ', ');
         }
     }
     Plugin::hook('cml.before_cml_stop');
     exit(json_encode($this->args, PHP_VERSION >= '5.4.0' ? JSON_UNESCAPED_UNICODE : 0));
 }
開發者ID:zonquan,項目名稱:cmlphp,代碼行數:16,代碼來源:Json.php

示例14: parseResourceFile

 /**
  * 解析一個靜態資源的內容
  *
  */
 public static function parseResourceFile()
 {
     $pathinfo = Route::getPathInfo();
     array_shift($pathinfo);
     $resource = implode('/', $pathinfo);
     if ($GLOBALS['debug'] && CML_IS_MULTI_MODULES) {
         $pos = strpos($resource, '/');
         $file = CML_APP_MODULES_PATH . DIRECTORY_SEPARATOR . substr($resource, 0, $pos) . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name') . substr($resource, $pos);
         if (is_file($file)) {
             Response::sendContentTypeBySubFix(substr($resource, strrpos($resource, '.') + 1));
             exit(file_get_contents($file));
         } else {
             Response::sendHttpStatus(404);
         }
     }
 }
開發者ID:zonquan,項目名稱:cmlphp,代碼行數:20,代碼來源:StaticResource.php

示例15: delete

 /**
  * 刪除session值
  *
  * @param string $key 要刪除的session的key
  *
  * @return string
  */
 public static function delete($key)
 {
     empty(self::$prefix) && (self::$prefix = Config::get('session_prefix'));
     if (is_array($key)) {
         foreach ($key as $k) {
             if (isset($_SESSION[self::$prefix . $k])) {
                 unset($_SESSION[self::$prefix . $k]);
             }
         }
     } else {
         if (isset($_SESSION[self::$prefix . $key])) {
             unset($_SESSION[self::$prefix . $key]);
         }
     }
     return true;
 }
開發者ID:linhecheng,項目名稱:cmlphp,代碼行數:23,代碼來源:Session.php


注:本文中的Cml\Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。