Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could do this by implementing custom <code>ErrorHandler</code> and overriding some of <code>AppKernel</code> methods. For example:</p> <pre><code>class AppKernel { protected $prodErrorHandler; public function init() { if ($this-&gt;debug) { ini_set('display_errors', 1); error_reporting(-1); DebugUniversalClassLoader::enable(); ErrorHandler::register(); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); } } else { ini_set('display_errors', 0); error_reporting(-1); $this-&gt;prodErrorHandler = new CustomErrorHandler(); set_error_handler(array($this-&gt;prodErrorHandler, 'handle')); } } public function boot() { $booted = $this-&gt;booted; parent::boot(); if (!$booted &amp;&amp; $this-&gt;prodErrorHandler !== null &amp;&amp; $this-&gt;container-&gt;has('logger')) { $this-&gt;prodErrorHandler-&gt;setLogger($this-&gt;container-&gt;get('logger')); } } // ... other methods } class CustomErrorHandler { protected $logger; protected $buffer = array(); public function setLogger($logger) { $this-&gt;logger = $logger; foreach ($this-&gt;buffer as $error) { $this-&gt;logger-&gt;warning($error); } $this-&gt;buffer = array(); } public function handle($level, $message, $file, $line, $context) { if (error_reporting() &amp; $level) { $error = new \ErrorException(sprintf('%s: %s in %s line %d', isset($this-&gt;levels[$level]) ? $this-&gt;levels[$level] : $level, $message, $file, $line)); if ($this-&gt;logger !== null) { $this-&gt;logger-&gt;warning($error); } else { $this-&gt;buffer[] = $error; } return true; // this would skip logging to file etc. Return false to just log and pass error handling to other handlers } else { return false; } } } </code></pre> <p>Something similar can be done with separate Bundle too, but it can "skip" some of errors occurred before bundle is registered.</p> <p>If you use <code>Monolog 1.6</code> or later, you can also use <a href="https://github.com/Seldaek/monolog/blob/1.6.0/src/Monolog/ErrorHandler.php" rel="nofollow"><code>Monolog\ErrorHandler</code></a> to register logger for errors, unhandled exceptions and fatal errors.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload