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'){
          $this->redirect(array('action'=>'error','controller'=>'pages'));
        } 
		
    }

You can customize error code is easy.

Web developer, big fan of CakePHP, loving wordpress soo much. You can found him on Google+ and Facebook. Dont forget to follow him on Twitter.
Posts created 562

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.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top