本文整理汇总了PHP中Pi::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Pi::get方法的具体用法?PHP Pi::get怎么用?PHP Pi::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pi
的用法示例。
在下文中一共展示了Pi::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
//初始化pipe
$default_pipe = array('WebReqPipe' => 'default', 'WebRouterPipe' => 'default');
$pipes = Pi::get('global.pipes', array());
if (empty($pipes)) {
$pipes = $default_pipe;
}
$this->pipeLoadContainer = $pipes;
parent::run();
}
示例2: getConfig
public static function getConfig($name)
{
$conf = Pi::get('cache.' . $name, array());
if (empty($conf)) {
return null;
}
foreach ($conf as $server) {
if (!isset($server['host']) || !isset($server['port']) || !isset($server['port']) || !isset($server['pconnect'])) {
return null;
}
}
return $conf;
}
示例3: _initLogger
protected function _initLogger()
{
//获得log path
if (!defined("LOG_PATH")) {
define("LOG_PATH", Pi::get('log.path', ''));
}
if (!is_dir(LOG_PATH)) {
die('pi.err can not find the log path');
}
Pi::inc(Pi::get('LogLib'));
$logFile = $this->task_name;
$logLevel = $this->debug === true ? Logger::LOG_DEBUG : Pi::get('log.level', Logger::LOG_TRACE);
$roll = Pi::get('log.roll', Logger::DAY_ROLLING);
$basic = array('logid' => $this->appId);
Logger::init(LOG_PATH, $logFile, $logLevel, array(), $roll);
Logger::addBasic($basic);
}
示例4: getConfig
private static function getConfig($name)
{
$c = Pi::get('db.' . $name, null);
$conf = array();
if (empty($c) || !is_array($c)) {
return null;
}
if (!isset($c['master']) && isset($c['slave'])) {
$conf['master'] = $c['slave'];
} else {
if (!isset($c['master']) && !isset($c['slave'])) {
$conf['master'] = $c;
} else {
$conf = $c;
}
}
foreach ($conf as $k => $v) {
if ($k != 'master' && $k != 'slave') {
unset($conf[$k]);
continue;
}
//端口默认 3306
if (!isset($conf[$k]['port'])) {
$conf[$k]['port'] = 3306;
}
//类型默认 mysql
if (!isset($conf[$k]['database_type'])) {
$conf[$k]['database_type'] = 'mysql';
}
//默认字符集
if (!isset($conf[$k]['charset'])) {
$conf[$k]['charset'] = 'utf8';
}
if (!isset($conf[$k]['prefix'])) {
$conf[$k]['prefix'] = '';
}
}
if (empty($conf)) {
return null;
}
return $conf;
}
示例5: run
public function run()
{
//内网api调用
if ($this->checkInnerApi()) {
//如果有其他调试输出忽略
ob_start();
define("USE_INNER_API", 1);
Pi::inc(PI_CORE . 'Proxy.php');
PiProxyServer::Server();
} else {
//初始化pipe
$default_pipe = array('ApiReqPipe' => 'default', 'ApiHttpRouterPipe' => 'default');
$pipes = Pi::get('global.pipes', array());
if (empty($pipes)) {
$pipes = $default_pipe;
}
$this->pipeLoadContainer = $pipes;
parent::run();
}
}
示例6: picom
function picom($mod, $add = '', $is_server = false)
{
$mod = strtolower($mod);
$add = strtolower($add);
//服务器端自身模块不再远程调用
static $rpc_mod = array();
if ($is_server !== false) {
$rpc_mod[$mod] = 1;
}
//客户端是否走远程加载
$rpc_conf = Pi::get('proxy.' . $mod, array());
if (!empty($rpc_conf) && $is_server === false && !isset($rpc_mod[$mod])) {
Pi::inc(PI_CORE . 'Proxy.php');
$rpc = new PI_PRC($mod, $add, $rpc_conf);
return $rpc;
}
if ($add == '') {
$cls = ucfirst($mod) . 'Export';
$file = EXPORT_ROOT . $mod . DOT . $cls . '.php';
} else {
if (is_string($add)) {
$cls = ucfirst($mod) . ucfirst($add) . 'Export';
$file = EXPORT_ROOT . $mod . DOT . $cls . '.php';
} else {
throw new Exception('picom can not find mod:' . $mod, ',add:' . $add, 1001);
}
}
if (is_readable($file)) {
Pi::inc($file);
if (class_exists($cls)) {
$class = new $cls();
if (!is_subclass_of($class, 'Export')) {
throw new Exception('the class ' . $cls . ' is not the subclass of Export', 1002);
}
return $class;
} else {
throw new Exception('can not find picom class ' . $cls . ' from ' . $file, 1003);
}
}
throw new Exception('can not read mod file: ' . $file . ' from picom func', 1004);
}
示例7: picom
function picom($mod, $add = '', $is_server = false)
{
$mod = strtolower($mod);
$add = strtolower($add);
//加载一次
static $loaded_mod = array();
if (isset($loaded_mod[$mod . $add])) {
return $loaded_mod[$mod . $add];
}
//先检测有没有远程配置,如果没有直接加载类,提高效率
$conf_add = $add == '' ? '' : '#' . $add;
$conf_name = 'proxy.' . strtolower($mod) . $conf_add;
$proxy_conf = Pi::get($conf_name, array());
if ($is_server === false && !empty($proxy_conf)) {
//proxy代理类,根据更详细的配置选择哪个接口走远程
$class = new Proxy($mod, $add, $proxy_conf);
$loaded_mod[$mod . $add] = $class;
} else {
//直接加载本地逻辑接口
$loaded_mod[$mod . $add] = pi_load_export_file($mod, $add);
}
return $loaded_mod[$mod . $add];
}
示例8: loadPipes
function loadPipes($pipes = null, $root = null)
{
//pipe 数组格式 path => class_name
//加载默认的处理管道
if ($pipes == null) {
$pipes = array();
$input = Pi::get('DefaultInputPipe');
$output = Pi::get('DefaultOutputPipe');
$pipes = array($input => PI_PIPE . $input . '.php', $output => PI_PIPE . $output . '.php');
} else {
if (is_string($pipes)) {
$pipes = array($pipes);
}
if (empty($pipes)) {
return false;
}
//加载管道位置
$root = $root == 'default' ? PI_ROOT : COM_ROOT;
foreach ($pipes as $k => $cls) {
$pipes[$cls] = $root . 'pipe' . DOT . $cls . '.php';
unset($pipes[$k]);
}
}
foreach ($pipes as $cls => $path) {
if (isset($this->arr_pipe[$cls])) {
continue;
}
if (is_readable($path)) {
Pi::inc($path);
if (class_exists($cls)) {
$this->arr_pipe[$cls] = new $cls();
}
} else {
throw new Exception('the pipe ' . $cls . ' can not load,check pipe file', 1020);
}
}
}
示例9: call
public function call($method, $params, $mod, $add, $conf)
{
$sign = Pi::get('global.innerapi_sign', '');
$sign_name = Pi::get('global.innerapi_sign_name', '_pi_inner_nm');
if (isset($conf['ip']) && isset($conf['net']) && $conf['net'] == 'http') {
$args = array();
$args['mod'] = $mod;
$args['add'] = $add;
$args['method'] = $method;
$args['param'] = $params;
$args[$sign_name] = $sign;
try {
$curl = new HttpClient();
$timeout = isset($conf['timeout']) ? intval($conf['timeout']) : 10;
$res = $curl->sendPostData($conf['ip'], $args, $timeout);
if ($curl->hasError() === false) {
$data = unserialize($res);
$data = isset($data[INNER_RES_PACK]) ? $data[INNER_RES_PACK] : $data;
return $data;
} else {
throw new Exception('curl error', 5011);
}
} catch (Exception $e) {
return array(INNER_ERR => 5011, 'msg' => $curl->getErrorMsg());
}
}
throw new Exception('inner api err conf : ' . var_export($conf), 5004);
}
示例10: needToLog
protected function needToLog($code)
{
$core_no_need_log_code = Conf::get('global.nolog_exception', array());
$app_no_need_log_code = Pi::get('global.nolog_exception', array());
if (isset($core_no_need_log_code[$code]) || isset($app_no_need_log_code[$code])) {
return false;
}
return true;
}
示例11: __construct
public function __construct()
{
//包含controller需要继承的父类
Pi::inc(Pi::get('PageCtr'));
}
示例12: initCache
protected function initCache()
{
$is_enable_memcache = Pi::get('global.enable_memcache', true);
$is_enable_redis = Pi::get('global.enable_redis', true);
if ($is_enable_memcache) {
Pi::inc(Pi::get('MemcacheLib'));
}
if ($is_enable_redis) {
Pi::inc(Pi::get('RedisLib'));
}
}
示例13: checkSign
static function checkSign($mod, $sign)
{
$sign = explode('_', $sign);
if (!isset($sign[1])) {
return false;
}
$salt = Pi::get('global.inner_tmp_salt', 'ks92pi');
if ($sign[0] == md5($mod . $salt . $sign[1])) {
return true;
}
return false;
}