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


PHP Run::writeToOutput方法代码示例

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


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

示例1: __construct

 /**
  * @param Run $whoops
  */
 public function __construct(Run $whoops)
 {
     $this->whoops = $whoops;
     $this->whoops->allowQuit(false);
     $this->whoops->writeToOutput(false);
     $this->whoops->pushHandler(new PrettyPageHandler());
 }
开发者ID:Mosaic,项目名称:Mosaic,代码行数:10,代码来源:WhoopsFormatter.php

示例2: onException

 /**
  * Handle http exceptions
  *
  * @param UnknownHttpExceptionEvent $event
  */
 public function onException(UnknownHttpExceptionEvent $event)
 {
     if (!$this->environment->equals(Environment::DEVELOPMENT)) {
         return;
     }
     $event->stopPropagation();
     $this->whoops->writeToOutput(false);
     $this->whoops->allowQuit(false);
     $content = $this->whoops->handleException($event->getHttpException());
     $event->getResponse()->setContent($content);
 }
开发者ID:thinframe,项目名称:karma,代码行数:16,代码来源:WhoopsListener.php

示例3: __toString

 /**
  * Convert the view to a rendered string.
  *
  * @return string A string of HTML, e.g. to be `echo`'d.
  */
 public function __toString()
 {
     static $run, $handler;
     if (!isset($run, $handler)) {
         $run = new Run();
         $handler = new PrettyPageHandler();
         $handler->handleUnconditionally(true);
         $run->pushHandler($handler);
         $run->allowQuit(false);
         $run->writeToOutput(false);
         $run->register();
     }
     // __toString cannot throw an exception, so we need to handle those
     // manually to prevent PHP from barfing:
     try {
         return $this->render();
     } catch (Exception $e) {
         self::$didWhoops = true;
         if (!static::$swallowError) {
             return $run->handleException($e);
         } else {
             return static::$swallowError;
         }
     }
 }
开发者ID:monomelodies,项目名称:improse,代码行数:30,代码来源:View.php

示例4: provideServices

 /**
  * Saving Application instance for later use
  *
  * @param Container $container
  * @return void
  */
 public function provideServices(Container $container)
 {
     $this->container = $container;
     /*
      * Creating and registering our error handler
      */
     $whoops = new Run();
     $whoops->register();
     /** @var \Venta\Contracts\Kernel\Kernel $kernel */
     $kernel = $container->get(Kernel::class);
     if ($kernel->isCli()) {
         // We don't need pretty pages in cli mode
         $whoops->allowQuit(true);
         $whoops->sendHttpCode(false);
         $whoops->writeToOutput(true);
         $whoops->pushHandler(new PlainTextHandler());
     } else {
         // Push pretty page handler only for local environment
         $whoops->pushHandler($kernel->getEnvironment() === 'local' ? new PrettyPageHandler() : new PlainTextHandler());
     }
     /**
      * Bind error handler
      */
     $container->bindClass(RunInterface::class, $whoops, ['error_handler']);
     /*
      * Bind PSR-3 logger
      */
     $container->share(\Monolog\Logger::class, function (Container $c) {
         $logger = new \Monolog\Logger('venta');
         $handler = new \Monolog\Handler\StreamHandler(__DIR__ . '/../storage/logs/app.log');
         $handler->pushProcessor(function ($record) use($c) {
             /** @var \Venta\Contracts\Kernel\Kernel $kernel */
             $kernel = $c->get(Kernel::class);
             if ($kernel->isCli()) {
                 // Add cli command related extra info
                 /** @var \Symfony\Component\Console\Input\InputInterface $input */
                 $input = $c->get(InputInterface::class);
                 $record['extra']['command'] = $input->getFirstArgument();
                 $record['extra']['arguments'] = $input->getArguments();
                 $record['extra']['options'] = $input->getOptions();
             } else {
                 // Add HTTP request related extra info
                 /** @var \Psr\Http\Message\ServerRequestInterface $request */
                 $request = $c->get(ServerRequestInterface::class);
                 $server = $request->getServerParams();
                 $record['extra']['url'] = $request->getUri()->getPath();
                 $record['extra']['http_method'] = $request->getMethod();
                 $record['extra']['host'] = $request->getUri()->getHost();
                 $record['extra']['referer'] = $request->getHeader('referer');
                 $record['extra']['user_agent'] = $request->getHeader('user-agent');
                 $record['extra']['ip'] = $server['REMOTE_ADDR'] ?? null;
             }
             return $record;
         });
         $handler->setFormatter(new \Monolog\Formatter\LineFormatter());
         $logger->pushHandler($handler);
         return $logger;
     }, ['logger', LoggerInterface::class]);
 }
开发者ID:venta,项目名称:framework,代码行数:65,代码来源:ErrorHandlerProvider.php

示例5: getWhoops

 /**
  * Returns the whoops instance.
  *
  * @return Whoops
  */
 private function getWhoops()
 {
     $whoops = new Whoops();
     $whoops->allowQuit(false);
     $whoops->writeToOutput(false);
     $whoops->pushHandler(new PrettyPageHandler());
     return $whoops;
 }
开发者ID:narrowspark,项目名称:framework,代码行数:13,代码来源:WhoopsDisplayer.php

示例6: handleWithWhoops

 protected function handleWithWhoops(Exception $exception)
 {
     $whoops = new Run();
     $whoops->allowQuit(false);
     $whoops->writeToOutput(false);
     $whoops->pushHandler(new PrettyPageHandler());
     return $whoops->handleException($exception);
 }
开发者ID:autarky,项目名称:framework,代码行数:8,代码来源:DefaultErrorHandler.php

示例7: renderExceptionWithWhoops

 /**
  * Render an exception using Whoops.
  *
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 protected function renderExceptionWithWhoops(Exception $e)
 {
     $whoops = new Whoops\Run();
     $whoops->allowQuit(false);
     $whoops->writeToOutput(false);
     $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler());
     return response($whoops->handleException($e), 500);
 }
开发者ID:matiux,项目名称:lumen-expander,代码行数:14,代码来源:ExceptionHandler.php

示例8: whoops

 /**
  * Get the whoops instance.
  *
  * @return \Whoops\Run
  */
 protected function whoops()
 {
     $whoops = new Whoops();
     $whoops->allowQuit(false);
     $whoops->writeToOutput(false);
     $whoops->pushHandler(new Handler());
     return $whoops;
 }
开发者ID:ssomenzi,项目名称:silence,代码行数:13,代码来源:DebugDisplayer.php

示例9: __invoke

 /**
  * Create and return an instance of the Whoops runner.
  *
  * @param ContainerInterface $container
  * @return Whoops
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $config = isset($config['whoops']) ? $config['whoops'] : [];
     $whoops = new Whoops();
     $whoops->writeToOutput(false);
     $whoops->allowQuit(false);
     $whoops->pushHandler($container->get('Zend\\Expressive\\WhoopsPageHandler'));
     $this->registerJsonHandler($whoops, $config);
     $whoops->register();
     return $whoops;
 }
开发者ID:kingjerod,项目名称:zend-expressive,代码行数:18,代码来源:WhoopsFactory.php

示例10: registerWhoops

 /**
  * Register the Whoops error display service.
  *
  * @return void
  */
 protected function registerWhoops()
 {
     $this->registerWhoopsHandler();
     $this->app['whoops'] = $this->app->share(function ($app) {
         // We will instruct Whoops to not exit after it displays the exception as it
         // will otherwise run out before we can do anything else. We just want to
         // let the framework go ahead and finish a request on this end instead.
         with($whoops = new Run())->allowQuit(false);
         $whoops->writeToOutput(false);
         return $whoops->pushHandler($app['whoops.handler']);
     });
 }
开发者ID:nova-framework,项目名称:cms,代码行数:17,代码来源:ExceptionServiceProvider.php

示例11: render

 /**
  * Render an exception into an HTTP response.
  *
  * When debugging is enabled, we make the error pretty using Whoops
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception                $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($this->isHttpException($e)) {
         return $this->renderHttpException($e);
     }
     if (config('app.debug')) {
         $whoops = new Run();
         $whoops->pushHandler($request->ajax() ? new JsonResponseHandler() : new PrettyPageHandler());
         $whoops->allowQuit(false);
         $whoops->writeToOutput(false);
         return response($whoops->handleException($e), $whoops->sendHttpCode());
     }
     return parent::render($request, $e);
 }
开发者ID:guidovanbiemen,项目名称:laravel-whoops,代码行数:23,代码来源:ExceptionHandler.php

示例12: handle

 public function handle(Request $request, $statusCode)
 {
     $runner = new Run();
     $format = $request->getRequestFormat();
     if ('html' == $format) {
         $handler = new PrettyPageHandler();
         $handler->addDataTable('App', ['Controller' => $request->get('_controller'), 'Route' => $request->get('_route'), 'Session' => $request->hasSession(), 'Status' => $this->getCodeWithDescription($statusCode)]);
     } else {
         if ('json' == $format) {
             $handler = new JsonResponseHandler();
         } else {
             $handler = new PlainTextHandler();
         }
     }
     $runner->pushHandler($handler);
     $runner->writeToOutput(false);
     $runner->allowQuit(false);
     $runner->register();
     return $runner;
 }
开发者ID:kejwmen,项目名称:WhoopsBundle,代码行数:20,代码来源:WhoopsHandler.php

示例13: dirname

<?php

include dirname(__DIR__) . '/vendor/autoload.php';
use lithium\core\ErrorHandler;
use Whoops\Run;
use Whoops\Handler\PrettyPageHandler;
ErrorHandler::apply('lithium\\action\\Dispatcher::run', array(), function ($info, $params) {
    $run = new Run();
    $handler = new PrettyPageHandler();
    $jsonHandler = new \Whoops\Handler\JsonResponseHandler();
    $jsonHandler->onlyForAjaxRequests(true);
    $run->pushHandler($handler);
    $run->pushHandler($jsonHandler);
    $request = $params['request'];
    $exception = $info['exception'];
    $handler->addDataTable('Request', array('URL' => $request->url, 'Query String' => isset($request->params['query']) ? $request->params['query'] : '<none>', 'HTTP Host' => $request->get('http:host'), 'HTTP Method' => $request->get('http:method'), 'Base Path' => $request->path, 'Scheme' => $request->scheme, 'Port' => $request->port, 'Host' => $request->host, 'Auth' => $request->auth, 'Username' => $request->username, 'Password' => $request->password, 'Protocol' => $request->protocol, 'Version' => $request->version));
    $handler->addDataTable('Params', $request->params);
    $handler->addDataTable('Data', $request->data);
    $handler->addDataTable('Headers', $request->headers);
    $handler->addDataTable('Cookies', $request->cookies);
    $handler->addDataTable('Body', $request->body);
    $run->writeToOutput(false);
    return $run->handleException($exception);
});
开发者ID:notomato,项目名称:li3_whoops,代码行数:24,代码来源:bootstrap.php

示例14: initializeErrorHandler

 /**
  * Initializes the error handler.
  * @return ErrorHandler The initializes error handler
  */
 private function initializeErrorHandler() : ErrorHandler
 {
     $errorHandler = new ErrorHandler();
     $errorHandler->allowQuit(false);
     $errorHandler->writeToOutput(false);
     if ($this->errorLog !== null) {
         $logger = new PlainTextHandler($this->getErrorLogger());
         $logger->loggerOnly(true);
         $errorHandler->pushHandler($logger);
     }
     if ($this->debug) {
         if ($this->jsonRequest) {
             $responseHandler = new JsonResponseHandler();
             $responseHandler->addTraceToOutput(true);
         } else {
             $responseHandler = new PrettyPageHandler();
         }
         $errorHandler->pushHandler($responseHandler);
     }
     return $errorHandler;
 }
开发者ID:phurity,项目名称:application,代码行数:25,代码来源:ErrorHandlerMiddleware.php

示例15: prepareWhoops

 /**
  * @param Whoops $whoops
  *
  * @return void
  */
 public function prepareWhoops(Whoops $whoops)
 {
     set_error_handler([$whoops, Whoops::ERROR_HANDLER]);
     $whoops->writeToOutput(false);
     $whoops->allowQuit(false);
 }
开发者ID:JasonBusse,项目名称:rest_scheduler,代码行数:11,代码来源:WhoopsConfiguration.php


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