The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

catching fatal error

lalop's Avatar


17 Sep, 2013 07:51 AM

I'm trying to work on a way to catch fatal error.
I'm trying to do that using register_shutdown_function.
I can log error but I don't find a way to send the error template to the user.
Here is my code :

    register_shutdown_function(function() use($app){
    if (null === $lastError = error_get_last()) {
    if (in_array($lastError['type'], $errors)) {
        $e = new ErrorException(
            @$lastError['message'], @$lastError['type'], @$lastError['type'],
            @$lastError['file'], @$lastError['line']

Doing so I get Fatal error: Uncaught exception 'Slim\Exception\Stop'
So how can I restart the app ?
And what do you think of this method to catch uncaught errors ?

  1. 1 Posted by kevin on 16 Oct, 2015 08:23 PM

    kevin's Avatar

    I've the same problem. Did you find a solution?

  2. 2 Posted by lalop on 16 Oct, 2015 09:16 PM

    lalop's Avatar

    not really sorry, but It seems that php7 solves this.

  3. 3 Posted by largo on 08 Jul, 2016 02:00 PM

    largo's Avatar

    Under PHP7, you can catch throwable Exceptions
    V: Slim Framework 2

     try {
      catch (\Throwable $e) {
       echo 'error'; 

    The problem is, that you can't render the normal error template that way.... :(
    Not sure If you can do that without changing the framework.

  4. Josh Lockhart closed this discussion on 12 Feb, 2021 07:37 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac