Disable fancy errors in CakePHP

Posted on 21 July 2009 (04:35 PM)

Here at work we often go crazy because of CakePHP's "helpful" displaying of error messages.

They are littered with HTML and, even worse, Javascript and provide an often superfluous stack trace, which makes it harder to read the actual error message.

If you just want readable, plain text error messages in your projects, add the following to /app/config/bootstrap.PHP:

  1. function displayErrorWithoutCrap() {
  2. // returning false here means the internal PHP error handler will take over again and display a neat, clean error
  3. return false;
  4. }
  5. set_error_handler('displayErrorWithoutCrap');
  6. Download this code: /code/disable_fancy_errors_in_cakephp1.txt

And if the Cake guys could make this configurable in their next release, that would just be awesome.

Back to top

Filed under PHP, CakePHP


No comments have been added yet, you could be the first!

Sorry, due to spam, comments are temporarily out of order.

Back to top


These settings will be saved for your convenience.