Ejemplo n.º 1
0
 public function dispatchLoopShutdown(Yaf\Request_Abstract $request, Yaf\Response_Abstract $response)
 {
     /**
      * phpConsole调试(需要安装google扩展)
      */
     PC::debug(Core\ServiceLocator::db()->log(), 'sql.trace');
     PC::debug(Core\ServiceLocator::db()->error(), 'sql.error');
     $performance = ['memory_usage' => memory_get_usage() - APP_MEMORY_START, 'time_usage' => microtime(true) - APP_MICROTIME_START];
     PC::debug($performance, 'performance.info');
 }
Ejemplo n.º 2
0
 public function _initService(Yaf\Dispatcher $dispatcher)
 {
     $service = Core\ServiceLocator::getInstance();
     //db
     $service->set('db', function () {
         return new Core\Connection($this->config['db']);
     });
     //log
     $service->set('log', function () {
         $logConfig = $this->config['log'];
         $log = new Monolog\Logger($logConfig['loger']);
         $log->pushHandler(new Monolog\Handler\StreamHandler($logConfig['path'] . '/' . date('Y-m-d') . '.log', Monolog\Logger::ERROR));
         return $log;
     });
     //rbac管理服务
     $service->set('rbacManage', function () {
         return new Service\rbac\Manage();
     });
 }