Custom Error Handling for CakePHP 2.xx

The main problem with CakePHP is error handling that hard to do. You need a lot of lines of code. This is in contrast with laravel, where the framework requires only 2 lines of code and everything is finished.

For CakePHP, finally I was able to find the proper error handling (for the moment), so that it can reduce the bad results of the URL was not found.

Just use the following code on AppController.php

public function beforeFilter() {
	 if($this->name == 'CakeError'){

You can customize error code is easy.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.