Esempio n. 1
0
 public function init()
 {
     // $this->data['uri']       = rtrim($this->data['uri'],'?& ');
     // $this->data['rootUrl']     = $this->scheme . ':/'.'/' . $this->name;
     // $this->data['referer']  = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->rootUrl;
     // $this->data['entryUrl']    = $this->rootUrl . $this->script;
     // $this->data['currentUrl']  = $this->isUrl($this->uri) ? $this->uri : $this->rootUrl . $this->uri;
     $this->sets(['workDir' => getcwd(), 'entry' => $this->getEntry(), 'root' => $this->getRoot(), 'isCli' => PhpHelper::isCli(), 'isWeb' => PhpHelper::isWeb(), 'os' => PHP_OS, 'osShort' => strtoupper(substr(PHP_OS, 0, 3)), 'isUnix' => $this->isUnix()])->set('isWin', $this->get('osShort') == 'WIN')->set('isLinux', $this->get('osShort') == 'LIN');
 }
Esempio n. 2
0
 public function exception(\Exception $e, array $context = [], $logRequest = true)
 {
     $message = $e->getMessage() . PHP_EOL;
     $message .= 'Called At ' . $e->getFile() . ', On Line: ' . $e->getLine() . PHP_EOL;
     $message .= 'Catch the exception by: ' . get_class($e);
     $message .= "\nCode Trace :\n" . $e->getTraceAsString();
     // If log the request info
     if ($logRequest && !PhpHelper::isCli()) {
         $message .= PHP_EOL;
         $context['request'] = ['HOST' => $this->getServer('HTTP_HOST'), 'METHOD' => $this->getServer('request_method'), 'URI' => $this->getServer('request_uri'), 'DATA' => $_REQUEST, 'REFERER' => $this->getServer('HTTP_REFERER')];
     }
     $this->format .= PHP_EOL;
     $this->log('exception', $message, $context);
     return $this->save();
 }