当前位置: 首页>>代码示例>>PHP>>正文


PHP Whoops\Run类代码示例

本文整理汇总了PHP中Whoops\Run的典型用法代码示例。如果您正苦于以下问题:PHP Run类的具体用法?PHP Run怎么用?PHP Run使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Run类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerWhoops

 protected static function registerWhoops()
 {
     $app = Slim::getInstance();
     $app->container->singleton('whoopsPrettyPageHandler', function () {
         return new PrettyPageHandler();
     });
     $app->whoopsSlimInfoHandler = $app->container->protect(function () use($app) {
         try {
             $request = $app->request();
         } catch (\RuntimeException $e) {
             return;
         }
         $current_route = $app->router()->getCurrentRoute();
         $route_details = array();
         if ($current_route !== null) {
             $route_details = array('Route Name' => $current_route->getName() ?: '<none>', 'Route Pattern' => $current_route->getPattern() ?: '<none>', 'Route Middleware' => $current_route->getMiddleware() ?: '<none>');
         }
         $app->whoopsPrettyPageHandler->addDataTable('Slim Application', array_merge(array('Charset' => $request->headers('ACCEPT_CHARSET'), 'Locale' => $request->getContentCharset() ?: '<none>', 'Application Class' => get_class($app)), $route_details));
         $app->whoopsPrettyPageHandler->addDataTable('Slim Application (Request)', array('URI' => $request->getRootUri(), 'Request URI' => $request->getResourceUri(), 'Path' => $request->getPath(), 'Query String' => $request->params() ?: '<none>', 'HTTP Method' => $request->getMethod(), 'Script Name' => $request->getScriptName(), 'Base URL' => $request->getUrl(), 'Scheme' => $request->getScheme(), 'Port' => $request->getPort(), 'Host' => $request->getHost()));
     });
     // Open with editor if editor is set
     $whoops_editor = $app->config('whoops.editor');
     if ($whoops_editor !== null) {
         $app->whoopsPrettyPageHandler->setEditor($whoops_editor);
     }
     $app->container->singleton('whoops', function () use($app) {
         $run = new Run();
         $run->pushHandler($app->whoopsPrettyPageHandler);
         $run->pushHandler($app->whoopsSlimInfoHandler);
         return $run;
     });
 }
开发者ID:kommuna,项目名称:restmodel,代码行数:32,代码来源:Controller.php

示例2: register

 /**
  * @see Silex\ServiceProviderInterface::register
  * @param  Silex\Application $app
  */
 public function register(Application $app)
 {
     // There's only ever going to be one error page...right?
     $app['whoops.error_page_handler'] = $app->share(function () {
         return new PrettyPageHandler();
     });
     // Retrieves info on the Silex environment and ships it off
     // to the PrettyPageHandler's data tables:
     // This works by adding a new handler to the stack that runs
     // before the error page, retrieving the shared page handler
     // instance, and working with it to add new data tables
     $app['whoops.silex_info_handler'] = $app->protect(function () use($app) {
         try {
             $request = $app['request'];
         } catch (RuntimeException $e) {
             // This error occurred too early in the application's life
             // and the request instance is not yet available.
             return;
         }
         // General application info:
         $app['whoops.error_page_handler']->addDataTable('Silex Application', array('Charset' => $app['charset'], 'Locale' => $app['locale'], 'Route Class' => $app['route_class'], 'Dispatcher Class' => $app['dispatcher_class'], 'Application Class' => get_class($app)));
         // Request info:
         $app['whoops.error_page_handler']->addDataTable('Silex Application (Request)', array('URI' => $request->getUri(), 'Request URI' => $request->getRequestUri(), 'Path Info' => $request->getPathInfo(), 'Query String' => $request->getQueryString() ?: '<none>', 'HTTP Method' => $request->getMethod(), 'Script Name' => $request->getScriptName(), 'Base Path' => $request->getBasePath(), 'Base URL' => $request->getBaseUrl(), 'Scheme' => $request->getScheme(), 'Port' => $request->getPort(), 'Host' => $request->getHost()));
     });
     $app['whoops'] = $app->share(function () use($app) {
         $run = new Run();
         $run->pushHandler($app['whoops.error_page_handler']);
         $run->pushHandler($app['whoops.silex_info_handler']);
         return $run;
     });
     $app->error(array($app['whoops'], Run::EXCEPTION_HANDLER));
     $app['whoops']->register();
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:37,代码来源:WhoopsServiceProvider.php

示例3: registerWhoops

 /**
  * registerWhoops
  *
  * @return void
  */
 public static function registerWhoops()
 {
     self::$whoops = new Run();
     self::$handler = new PrettyPageHandler();
     self::$whoops->pushHandler(self::$handler);
     self::$whoops->register();
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:12,代码来源:Debugger.php

示例4: registerErrorHandler

 /**
  * Register the error handler for the application.
  */
 private function registerErrorHandler()
 {
     $run = new Whoops\Run();
     $handler = new PlainTextHandler();
     $run->pushHandler($handler);
     $run->register();
 }
开发者ID:pugphp,项目名称:framework,代码行数:10,代码来源:Application.php

示例5: _readConfigs

 private function _readConfigs()
 {
     $domain = 'cli';
     if (!$this->isRunningInConsole()) {
         $domain = str_replace('www.', '', $_SERVER['SERVER_NAME']);
     }
     $files = scandir(APP_ROOT . DS . 'Config' . DS);
     foreach ($files as $file) {
         if (preg_match("#{$domain}\\.php\$#", $file)) {
             $this['config']['app'] = (require APP_ROOT . '/Config/' . $file);
             continue;
         }
         if (preg_match('#(.+?)\\.php$#', $file, $matches)) {
             $this['config'][$matches[1]] = (require_once APP_ROOT . DS . 'Config' . DS . $file);
         }
     }
     $this['config']['database'] = $this['config']['database'][$this['config']['app']['environment']];
     if ($this['config']['app.debug'] === true) {
         error_reporting(E_ALL);
         ini_set("display_errors", 1);
         if (!$this->isRunningInConsole()) {
             $whoops = new Run();
             $whoops->pushHandler(new PrettyPageHandler());
             $whoops->register();
         }
     } else {
         error_reporting(0);
         ini_set("display_errors", 0);
         if (!$this->isRunningInConsole()) {
             ExceptionHandler::setApp($this);
             set_exception_handler('Primer\\Error\\ExceptionHandler::handleException');
         }
     }
 }
开发者ID:exonintrendo,项目名称:Primer,代码行数:34,代码来源:Application.php

示例6: debugRender

 /**
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 protected function debugRender(Exception $e)
 {
     $whoops = new WhoopsRun();
     $whoops->pushHandler(new WhoopsPrettyPageHandler());
     $response = $this->convertExceptionToResponse($e);
     return new HttpResponse($whoops->handleException($e), $response->getStatusCode(), $response->headers);
 }
开发者ID:jbenner-radham,项目名称:v-phoenix,代码行数:11,代码来源:Handler.php

示例7: __invoke

 public function __invoke($request, $response, $next)
 {
     $app = $next;
     $container = $app->getContainer();
     $settings = $container['settings'];
     if (isset($settings['debug']) === true && $settings['debug'] === true) {
         // Enable PrettyPageHandler with editor options
         $prettyPageHandler = new PrettyPageHandler();
         if (empty($settings['whoops.editor']) === false) {
             $prettyPageHandler->setEditor($settings['whoops.editor']);
         }
         // Enable JsonResponseHandler when request is AJAX
         $jsonResponseHandler = new JsonResponseHandler();
         $jsonResponseHandler->onlyForAjaxRequests(true);
         // Add more information to the PrettyPageHandler
         $prettyPageHandler->addDataTable('Slim Application', ['Application Class' => get_class($app), 'Script Name' => $app->environment->get('SCRIPT_NAME'), 'Request URI' => $app->environment->get('PATH_INFO') ?: '<none>']);
         $prettyPageHandler->addDataTable('Slim Application (Request)', array('Accept Charset' => $app->request->getHeader('ACCEPT_CHARSET') ?: '<none>', 'Content Charset' => $app->request->getContentCharset() ?: '<none>', 'Path' => $app->request->getUri()->getPath(), 'Query String' => $app->request->getUri()->getQuery() ?: '<none>', 'HTTP Method' => $app->request->getMethod(), 'Base URL' => (string) $app->request->getUri(), 'Scheme' => $app->request->getUri()->getScheme(), 'Port' => $app->request->getUri()->getPort(), 'Host' => $app->request->getUri()->getHost()));
         // Set Whoops to default exception handler
         $whoops = new \Whoops\Run();
         $whoops->pushHandler($prettyPageHandler);
         $whoops->pushHandler($jsonResponseHandler);
         $whoops->register();
         $container['errorHandler'] = function ($c) use($whoops) {
             return new WhoopsErrorHandler($whoops);
         };
         //
         $container['whoops'] = $whoops;
     }
     return $app($request, $response);
 }
开发者ID:BenHicksy,项目名称:dietddocs,代码行数:30,代码来源:WhoopsMiddleware.php

示例8: appException

 /**
  * 自定义异常处理
  *
  * @param mixed $e 异常对象
  */
 public function appException(&$e)
 {
     if (Cml::$debug) {
         $run = new Run();
         $run->pushHandler(Request::isCli() ? new PlainTextHandler() : new PrettyPageHandler());
         $run->handleException($e);
     } else {
         $error = [];
         $error['message'] = $e->getMessage();
         $trace = $e->getTrace();
         $error['files'][0] = $trace[0];
         if (substr($e->getFile(), -20) !== '\\Tools\\functions.php' || $e->getLine() !== 90) {
             array_unshift($error['files'], ['file' => $e->getFile(), 'line' => $e->getLine(), 'type' => 'throw']);
         }
         //正式环境 只显示‘系统错误’并将错误信息记录到日志
         Log::emergency($error['message'], [$error['files'][0]]);
         $error = [];
         $error['message'] = Lang::get('_CML_ERROR_');
         if (Request::isCli()) {
             \Cml\pd($error);
         } else {
             header('HTTP/1.1 500 Internal Server Error');
             View::getEngine('html')->reset()->assign('error', $error);
             Cml::showSystemTemplate(Config::get('html_exception'));
         }
     }
     exit;
 }
开发者ID:linhecheng,项目名称:cmlphp,代码行数:33,代码来源:Whoops.php

示例9: initWhoopsErrorHandler

 /**
  * Send any Exceptions or PHP errors to the Whoops! Error Handler
  *
  * @return $this
  */
 public function initWhoopsErrorHandler()
 {
     $whoops = new WhoopsRun();
     $handler = new WhoopsPrettyPageHandler();
     $whoops->pushHandler($handler)->register();
     return $this;
 }
开发者ID:boiler256,项目名称:simple-mvc,代码行数:12,代码来源:App.php

示例10: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     $whoops = new Run();
     $whoops->pushHandler(new PrettyPageHandler());
     $whoops->register();
 }
开发者ID:d33cktr4zy,项目名称:sigkat2.0.ta,代码行数:12,代码来源:ErrorServiceProvider.php

示例11: registerErrorHandler

 protected function registerErrorHandler()
 {
     $run = new WhoopsRun();
     $handler = new PrettyPageHandler();
     $run->pushHandler($handler);
     $run->register();
 }
开发者ID:hatcher-project,项目名称:hatcher-framework,代码行数:7,代码来源:Application.php

示例12: __invoke

 public function __invoke($request, $response, $next)
 {
     $container = $this->app->getContainer();
     $settings = DotArray::newDotArray($container['settings']);
     if ($settings['app.debug'] === true) {
         // Enable PrettyPageHandler with editor options
         $prettyPageHandler = new PrettyPageHandler();
         if ($settings->has('whoops.editor')) {
             $prettyPageHandler->setEditor($settings['whoops.editor']);
         }
         // Enable JsonResponseHandler when request is AJAX
         $jsonResponseHandler = new JsonResponseHandler();
         $jsonResponseHandler->onlyForAjaxRequests(true);
         // Add more information to the PrettyPageHandler
         $prettyPageHandler->addDataTable('Slim Application', ['Application Class' => get_class($this->app), 'Script Name' => $this->app->environment->get('SCRIPT_NAME'), 'Request URI' => $this->app->environment->get('PATH_INFO') ?: '<none>']);
         $prettyPageHandler->addDataTable('Slim Application (Request)', ['Accept Charset' => $this->app->request->getHeader('ACCEPT_CHARSET') ?: '<none>', 'Content Charset' => $this->app->request->getContentCharset() ?: '<none>', 'Path' => $this->app->request->getUri()->getPath(), 'Query String' => $this->app->request->getUri()->getQuery() ?: '<none>', 'HTTP Method' => $this->app->request->getMethod(), 'Base URL' => (string) $this->app->request->getUri(), 'Scheme' => $this->app->request->getUri()->getScheme(), 'Port' => $this->app->request->getUri()->getPort(), 'Host' => $this->app->request->getUri()->getHost()]);
         $prettyPageHandler->addDataTable('SlimFastShake Settings', $settings->flatten());
         // Set Whoops to default exception handler
         $whoops = new \Whoops\Run();
         $whoops->pushHandler($prettyPageHandler);
         $whoops->pushHandler($jsonResponseHandler);
         if (isset($container['logger'])) {
             $logger = $container['logger'];
             $whoops->pushHandler(function ($exception, $inspector, $run) use($logger) {
                 $logger->critical('Whoops: ' . $exception->getMessage());
             });
         }
         $whoops->register();
         $container['errorHandler'] = function ($c) use($whoops) {
             return new WhoopsErrorHandler($whoops);
         };
         $container['whoops'] = $whoops;
     }
     return $next($request, $response);
 }
开发者ID:itguy614,项目名称:slim-fast-shake,代码行数:35,代码来源:WhoopsMiddleware.php

示例13: getWhoopsInstance

 private static function getWhoopsInstance(ServerRequestInterface $request)
 {
     $whoops = new Run();
     if (php_sapi_name() === 'cli') {
         $whoops->pushHandler(new PlainTextHandler());
         return $whoops;
     }
     $format = FormatNegotiator::getPreferredFormat($request);
     switch ($format) {
         case 'json':
             $handler = new JsonResponseHandler();
             $handler->addTraceToOutput(true);
             break;
         case 'html':
             $handler = new PrettyPageHandler();
             break;
         case 'txt':
             $handler = new PlainTextHandler();
             $handler->addTraceToOutput(true);
             break;
         case 'xml':
             $handler = new XmlResponseHandler();
             $handler->addTraceToOutput(true);
             break;
         default:
             if (empty($format)) {
                 $handler = new PrettyPageHandler();
             } else {
                 $handler = new PlainTextHandler();
                 $handler->addTraceToOutput(true);
             }
     }
     $whoops->pushHandler($handler);
     return $whoops;
 }
开发者ID:skywalker512,项目名称:FlarumChina,代码行数:35,代码来源:WhoopsRunner.php

示例14: __construct

 /**
  * @param Phalcon\DI $di
  */
 public function __construct(DI $di = null)
 {
     if (!$di) {
         $di = DI::getDefault();
     }
     // There's only ever going to be one error page...right?
     $di->setShared('whoops.error_page_handler', function () {
         return new PrettyPageHandler();
     });
     // Retrieves info on the Phalcon environment and ships it off
     // to the PrettyPageHandler's data tables:
     // This works by adding a new handler to the stack that runs
     // before the error page, retrieving the shared page handler
     // instance, and working with it to add new data tables
     $phalcon_info_handler = function () use($di) {
         try {
             $request = $di['request'];
         } catch (Exception $e) {
             // This error occurred too early in the application's life
             // and the request instance is not yet available.
             return;
         }
         // Request info:
         $di['whoops.error_page_handler']->addDataTable('Phalcon Application (Request)', array('URI' => $request->getScheme() . '://' . $request->getServer('HTTP_HOST') . $request->getServer('REQUEST_URI'), 'Request URI' => $request->getServer('REQUEST_URI'), 'Path Info' => $request->getServer('PATH_INFO'), 'Query String' => $request->getServer('QUERY_STRING') ?: '<none>', 'HTTP Method' => $request->getMethod(), 'Script Name' => $request->getServer('SCRIPT_NAME'), 'Scheme' => $request->getScheme(), 'Port' => $request->getServer('SERVER_PORT'), 'Host' => $request->getServerName()));
     };
     $di->setShared('whoops', function () use($di, $phalcon_info_handler) {
         $run = new Run();
         $run->pushHandler($di['whoops.error_page_handler']);
         $run->pushHandler($phalcon_info_handler);
         return $run;
     });
     $di['whoops']->register();
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:36,代码来源:WhoopsServiceProvider.php

示例15: __construct

 /**
  * @param DI $di
  */
 public function __construct(DI $di = null)
 {
     if (!class_exists('\\Whoops\\Run')) {
         return;
     }
     if (!$di) {
         $di = DI::getDefault();
     }
     // There's only ever going to be one error page...right?
     $di->setShared('whoops.pretty_page_handler', function () use($di) {
         return (new DebugbarHandler())->setDi($di);
     });
     // There's only ever going to be one error page...right?
     $di->setShared('whoops.json_response_handler', function () {
         $jsonHandler = new JsonResponseHandler();
         $jsonHandler->onlyForAjaxRequests(true);
         return $jsonHandler;
     });
     $di->setShared('whoops', function () use($di) {
         $run = new Run();
         $run->silenceErrorsInPaths(array('/phalcon-debugbar/'), E_ALL);
         $run->pushHandler($di['whoops.pretty_page_handler']);
         $run->pushHandler($di['whoops.json_response_handler']);
         return $run;
     });
     $di['whoops']->register();
 }
开发者ID:minhlaoleu,项目名称:phalcon-debugbar,代码行数:30,代码来源:WhoopsServiceProvider.php


注:本文中的Whoops\Run类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。