$di->set('session', function () { $session = new Files(); $session->start(); return $session; }); if (!DEBUG) { register_shutdown_function(function () use($config) { $errInfo = error_get_last(); if ($errInfo && is_array($errInfo)) { error_log('[' . date('Y-m-d H:i:s') . ']' . var_export($errInfo, TRUE), 3, $config['application']['errorFile']); } }); } $class = 'index'; $url = isset($_GET['_url']) ? trim($_GET['_url']) : false; if (false != $url) { $urlArr = explode('/', $url); $class = $urlArr[1]; } $className = ucfirst($class) . 'Controller'; if (class_exists($className)) { \core\Config::init(DEBUG); $service = new Yar_Server(new $className($di)); $service->handle(); } else { throw new Exception('the rpc controllers not exits'); } } catch (\Exception $e) { echo json_encode(array('flag' => 0, 'msg' => 'system error')); file_put_contents($config['application']['logFile'], '[' . date("Y-m-d H:i:s") . ']' . $e->getMessage() . "\n", FILE_APPEND); }