Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Run your web requests through a <a href="https://stackoverflow.com/questions/20277102/proper-separation-difference-between-index-php-and-front-controller/20299496#20299496">Front Controller script</a></li> <li><p>call <a href="http://www.php.net/set_error_handler" rel="nofollow noreferrer"><code>set_exception_handler</code></a> early in execution (don't forget to account for <code>error_reporting()</code>). <code>set_exception_handler</code> takes as its paramter what php calls a <a href="http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback" rel="nofollow noreferrer">"callback"</a>. You can pass an object method like so:</p> <pre><code>// $object-&gt;methodName() will be called on errors set_exception_handler(array($object, 'methodName')); </code></pre></li> <li><p>Wrap your dispatching code with <code>try/catch</code> to catch any code that DOES throw exceptions. The catch part of your code will catch all your own codes' exceptions, plus <em>some</em> php errors that didn't generate an exception natively (eg <code>fopen</code> or something), thanks to your <code>set_exception_handler</code> call above. The php manual states:</p> <blockquote> <p>The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.</p> </blockquote></li> <li><p>Log errors as necessary.</p></li> <li><p>Create an error page template (the "View") that operates on an Exception object (the "Model") and pretty prints the whole stack trace for you, in development. Create a different template that goes to production. Branch on your environment, for example:</p> <pre><code>catch(Exception $e) { // log error as necessary here. if("in developement") { // $e would be available to your template at this point include "errortemplates/dev.php"; } else { include "errortemplates/prod.php"; } } </code></pre></li> </ol>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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