How To Catch PHP Fatal Error In CodeIgniter

January 1st, 2011 | Save to del.icio.us now(0)

My last few blog post’s are result of the project that I am currently working on, and this blog is also in that series.

We needed to catch PHP Fatal Errors in the production environment and notify about it to developers, also at the same time, showing our beautiful fail whale page to user instead of ugly error or a white screen of death.

Here I will show you how to do this in CodeIgniter, though credit for this idea goes to hipertracker.

First of all you will need to setup a hook, so update your hooks.php file with following code

	$hook['pre_system'][] = array(
	    'class'    => 'PHPFatalError',
            'function' => 'setHandler',
            'filename' => 'PHPFatalError.php',
   	    'filepath' => 'hooks'
);

Now put the code shown below in PHPFatalError.php file in your applications hooks folder.

This is the simplifed version of what I have done, so please update handleShutdown function as per your needs.

Check out PHPCamp a place to share news, views and articles that are useful to PHP community.

Related posts

  1. How to use SVN and Git together to get the best of both worlds in Windows
  2. How To Fix MySQL Error – Error Code 30
  3. How to Remove Antivirus XP 2008
  4. How to remove new folder exe or regsvr exe or autorun inf virus
  5. Easy File Uploading Solution For PHP

Wondering what to do next?


(Search web development related contents)


2 Responses to “How To Catch PHP Fatal Error In CodeIgniter”

  1. February 15, 2011 11:44 pm Pedram says

    I’m sorry to interrupt here
    but this post’s comments are closed
    http://amiworks.co.in/talk/how-to-remove-new-folderexe-or-regsvrexr-or-autoruninf-virus/

    I can’t delete “svchost .exe”
    it says:
    ————————
    Cannot delete svchost: Access is denied
    Make sure the disk is not full or write-protected and that the file is not currently in use.
    ————————

    what should I do?

    many thanks

  2. July 16, 2011 8:12 pm Sparrow says

    where are function load_page?

    I have error, PHP Fatal error: Call to undefined function load_page()

Trackback URI | Comments RSS

Say Something, and Be Counted

Name (required)

Email (required)

Website

Speak your mind