当前位置: 首页>>代码示例>>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;未经允许,请勿转载。