本文整理汇总了PHP中Pi::inc方法的典型用法代码示例。如果您正苦于以下问题:PHP Pi::inc方法的具体用法?PHP Pi::inc怎么用?PHP Pi::inc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pi
的用法示例。
在下文中一共展示了Pi::inc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php');
if (!is_readable($dispatcher) || !Pi::inc($dispatcher)) {
throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
}
}
示例2: __construct
public function __construct()
{
$dispatcher = Pcf::get('global.dispatcher_path', PIPE_HELPER . 'RouteDispatcher.php');
if (!Pi::inc($dispatcher)) {
throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
}
}
示例3: _pi_autoloader_core
function _pi_autoloader_core($class)
{
if (($pos = strpos($class, '_')) !== false) {
$class = explode('_', $class);
if (empty($class)) {
return false;
}
$first_dir = strtolower($class[0]);
$fileName = array_pop($class);
$class = array_map('strtolower', $class);
$root = $first_dir == 'util' ? PI_ROOT : COM_ROOT;
$file = $root . implode(DOT, $class) . DOT . $fileName . '.php';
if (is_readable($file)) {
Pi::inc($file);
}
} else {
//优先加载工程中的lib,其次加载框架中的util
if (is_readable(PI_UTIl . $class . '.php')) {
Pi::inc(PI_UTIl . $class . '.php');
} else {
if (is_readable(COM_ROOT . 'lib/' . $class . '.php')) {
Pi::inc(COM_ROOT . 'lib/' . $class . '.php');
}
}
}
}
示例4: execute
public function execute(App $app)
{
$argv = $app->argv;
$script = $app->task_name;
$script = explode('_', $script);
$cls_file = ucfirst(strtolower(array_pop($script)));
if (empty($cls_file)) {
throw new Exception('task.err for run the task for :' . $this->task_name, 1033);
}
$path = '';
$class = '';
if (!empty($script)) {
foreach ($script as $p) {
$p = strtolower($p);
$path .= $p . DOT;
$class .= ucfirst($p);
}
}
$class .= $cls_file;
$path = TASK_PATH . $path;
$file = $path . $cls_file . '.php';
Pi::inc(PI_CORE . 'BaseTask.php');
if (!Pi::inc($file)) {
throw new Exception('task.err can not load the file :' . $file, 1034);
}
if (!class_exists($class)) {
throw new Exception('task.err can not find the class :' . $class, 1035);
}
$cls = new $class();
if (!is_subclass_of($cls, 'BaseTask')) {
throw new Exception('task.err the class ' . $class . ' is not the subclass of BaseTask ', 1036);
}
$cls->execute($argv);
}
示例5: __construct
public function __construct()
{
$dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php');
if (file_exists($dispatcher)) {
Pi::inc($dispatcher);
} else {
throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
}
}
示例6: _initTemplate
protected function _initTemplate()
{
$views = Conf::get('global.view_lib_path');
if (!is_readable(PI_ROOT . $views)) {
die('can not find the web view libs ');
}
Pi::inc(PI_ROOT . $views);
$cls = Conf::get('global.view_engine');
if (!class_exists($cls)) {
die('can not init the template engine class');
}
}
示例7: initTemplate
protected function initTemplate()
{
$views = Pcf::get('global.view_lib_path');
$views = PI_UTIL . $views;
if (!Pi::inc($views)) {
die('can not find the web view libs ');
}
$cls = Pcf::get('global.view_engine');
if (!class_exists($cls)) {
die('can not init the template engine class');
}
}
示例8: dispatch
public function dispatch()
{
if (!$this->checkSign()) {
$this->output('api.err sign', 7099);
}
$mod_name = Pcf::get("global.mod", 'mod');
$func_name = Pcf::get("global.func", 'func');
$mod_seg = Pcf::get("global.mod_seg", '/');
$api_path = Pcf::get("global.base_path", PI_APP_ROOT . PI_APP_NAME . DOT . 'logic' . DOT);
$mod = Comm::Req($mod_name);
$func = Comm::Req($func_name);
$mod = explode($mod_seg, $mod);
$pattern = '/^[0-9a-zA-Z\\/]*$/';
$class = '';
if (!empty($mod)) {
foreach ($mod as $k => $m) {
if (empty($m) || !is_string($m)) {
if (!preg_match($pattern, $m)) {
$this->output('api.err error format mod:' . $m, 1005);
}
unset($mod[$k]);
}
$mod[$k] = strtolower($m);
$class .= ucfirst($mod[$k]);
}
}
if (empty($mod)) {
$this->output('api.err empty api mod:' . $mod, 1006);
}
if (empty($func) || !is_string($func) || !preg_match($pattern, $func)) {
$this->output('api.err empty or error api func:' . $func, 1007);
}
Pi::inc(PI_CORE . 'BaseApi.php');
$file = $api_path . implode(DOT, $mod) . DOT . $class . '.api.php';
if (!Pi::inc($file)) {
$this->output('api.err api router can not load file:' . $file, 1008);
}
if (!class_exists($class)) {
$this->output('api.err api router not find class:' . $class, 1009);
}
$cls = new $class();
if (!is_subclass_of($cls, 'PiBaseApi')) {
$this->output('api.err is not the subclass of BaseApi', 1010);
}
if (!is_callable(array($cls, $func))) {
$this->output('api.err api class:' . $class . ' can not call method:' . $func, 1011);
}
$res = Pi::piCallMethod($cls, $func);
return $res;
}
示例9: dispatch
public function dispatch()
{
$mod_name = Conf::get("global.mod", 'mod');
$func_name = Conf::get("global.func", 'func');
$mod_seg = Conf::get("global.mod_seg", '/');
$api_path = Conf::get("global.base_path", APP_ROOT . APP_NAME . DOT . 'logic' . DOT);
$mod = Comm::Req($mod_name);
$func = Comm::Req($func_name);
$mod = explode($mod_seg, $mod);
$pattern = '/^[0-9a-zA-Z\\/]*$/';
$class = '';
if (!empty($mod)) {
foreach ($mod as $k => $m) {
if (empty($m) || !is_string($m)) {
if (!preg_match($pattern, $m)) {
throw new Exception('error format mod:' . $m, 1005);
}
unset($mod[$k]);
}
$mod[$k] = strtolower($m);
$class .= ucfirst($mod[$k]);
}
}
if (empty($mod)) {
throw new Exception('empty api mod:' . $mod, 1006);
}
if (empty($func) || !is_string($func) || !preg_match($pattern, $func)) {
throw new Exception("empty api func:" . $func, 1007);
}
$file = $api_path . implode(DOT, $mod) . DOT . $class . '.api.php';
if (!is_readable($file)) {
throw new Exception('api router can not load file:' . $file, 1008);
}
Pi::inc(PI_CORE . 'BaseApi.php');
Pi::inc($file);
if (!class_exists($class)) {
throw new Exception('api router not find class:' . $class, 1009);
}
$cls = new $class();
if (!is_subclass_of($cls, 'BaseApi')) {
throw new Exception('api.err is not the subclass of BaseApi ', 1010);
}
$res = $this->_call_method($cls, $func);
if ($res === false) {
throw new Exception('api class:' . $class . ' call method ' . $func . ' err ', 1011);
}
}
示例10: _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);
}
示例11: execute
public function execute(PiApp $app)
{
$this->app = $app;
$router = Pcf::get('global.router_file', 'ApiRouter.php');
$router_class = Pcf::get('global.router_class', 'PiApiRouter');
if (!Pi::inc(PIPE_HELPER . $router)) {
throw new Exception('api.router can not find the api router : ' . $router, 1030);
}
if (class_exists($router_class)) {
$cls = new $router_class($app);
$res = $cls->dispatch();
//线上环境请处理输出做加密
$cls->output($res);
} else {
throw new Exception('api.router can not find the router class : ' . $router_class, 1031);
}
}
示例12: execute
public function execute(PiApp $app)
{
$this->app = $app;
$router = Conf::get('global.router_file', 'ApiRouter.php');
$router_class = Conf::get('global.router_class', 'PiApiRouter');
if (is_readable(PI_CORE . $router)) {
Pi::inc(PI_CORE . $router);
} else {
throw new Exception('api.router can not find the api router : ' . $router, 1030);
}
if (class_exists($router_class)) {
$cls = new $router_class($app);
$cls->dispatch();
} else {
throw new Exception('api.router can not find the router class : ' . $router_class, 1031);
}
}
示例13: 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();
}
}
示例14: 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);
}
}
}
示例15: get
static function get($key, $default = null)
{
if (isset(self::$saConfData[$key])) {
return self::$saConfData[$key];
}
//没有的自动加载文件和配置项
if (defined("APP_CONF_PATH") && strpos($key, '.') !== false) {
$file = explode('.', $key);
if (!empty($file)) {
array_pop($file);
$file_name = array_pop($file);
$file = count($file) == 0 ? '' : implode(DOT, $file) . DOT;
$file = APP_CONF_PATH . $file . $file_name . '.inc.php';
if (Pi::inc($file) && isset(self::$saConfData[$key])) {
return self::$saConfData[$key];
}
}
}
return $default;
}