Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pderiy's avatar
Level 19

PHP Fatal Error Illuminate\Exception\WhoopsDisplayer::display()

Hey, I'm using now old project with laravel 4.2-dev And after "composer update" I'have some unreadable errors...

 [RuntimeException]                                                           
  Error Output: PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Il  
  luminate\Exception\WhoopsDisplayer::display() must be an instance of Except  
  ion, instance of Error given, called in /media/storage/Linux/vagrant/Code/a  
  utolicytacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/Handle  
  r.php on line 280 and defined in /media/storage/Linux/vagrant/Code/autolicy  
  tacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplay  
  er.php:43                                                                    
  Stack trace:                                                                 
  #0 /media/storage/Linux/vagrant/Code/autolicytacje24.dev/vendor/laravel/fra  
  mework/src/Illuminate/Exception/Handler.php(280): Illuminate\Exception\Whoo  
  psDisplayer->display(Object(Error))                                          
  #1 /media/storage/Linux/vagrant/Code/autolicytacje24.dev/vendor/laravel/fra  
  mework/src/Illuminate/Exception/Handler.php(159): Illuminate\Exception\Hand  
  ler->displayException(Object(Error))                                         
  #2 /media/storage/Linux/vagrant/Code/autolicytacje24.dev/vendor/laravel/fra  
  mework/src/Illuminate/Exception/Handler.php(170): Illuminate\Exception\Hand  
  ler->handleException(Object(Error))                                          
  #3 [internal function]:  in /media/storage/Linux/vagrant/Code/autolicytacje  
  24.dev/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.ph  
  p on line 43

I tried to clean my composer.json from packages

"require": {
        "laravel/framework": "4.2.0"
    },

Home page, has this error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
HELP
Uncaught TypeError: Argument 1 passed to Illuminate\Exception\WhoopsDisplayer::display() must be an instance of Exception, instance of Error given, called in /home/vagrant/Code/autolicytacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/Handler.php on line 280 and defined in /home/vagrant/Code/autolicytacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php:43 Stack trace: #0 /home/vagrant/Code/autolicytacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/Handler.php(280): Illuminate\Exception\WhoopsDisplayer->display(Object(Error)) #1 /home/vagrant/Code/autolicytacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/Handler.php(159): Illuminate\Exception\Handler->displayException(Object(Error)) #2 /home/vagrant/Code/autolicytacje24.dev/vendor/laravel/framework/src/Illuminate/Exception/Handler.php(170): Illuminate\Exception\Handler->handleException(Object(Error)) #3 [internal function]: Illuminate\Exception\Handler->handleUncaughtException(Object(Error)) #4 {ma
0 likes
9 replies
dmeganoski@gmail.com's avatar

Yes, as the link points out this is not because of a composer update, but because of a php upgrade to 7. They changed error class names.

There is a temporary solution, and that is to remove the 'Exception' class requirements from those files, but modifying system files is never a good idea (especially in production), and can be overwritten the next time the package is updated.

It would be possible to replace the exception handlers yourself, but I have not yet found a pre-built solution to this.

2 likes
pderiy's avatar
Level 19

I'm using Phpstorm Xdebug, it helps me in this situation with this old project. Php storm can show u exception message before u will take Whoops Display Error...

sundaybk's avatar

If you want to see the errors you can do one of two things. One, you can push your code to a server with PHP5.6 and see the error or two, (which I think is much easier) is to adjust one line of a system file (which @dmeganoski doesn't recommend for good reason). If you add a return $exception on line 226 in vendor/laravel/framework/src/Illuminate/Exception/Handler.php it will skip laravel's fancy formatting and the whoops displayer error and give you a plain text error that you can actually do something with.

    protected function callCustomHandlers($exception, $fromConsole = false)
    {
        return $exception; // add this line
        foreach ($this->handlers as $handler)
        {
            // If this exception handler does not handle the given exception, we will just
            // go the next one. A handler may type-hint an exception that it handles so
            //  we can have more granularity on the error handling for the developer.
            if ( ! $this->handlesException($handler, $exception))
            {
                continue;
            }
            elseif ($exception instanceof HttpExceptionInterface)
            {
                $code = $exception->getStatusCode();
            }

Again, not the best long term solution but good enough until I upgrade my API to Laravel 5.* which is compatible with PHP7. Remember, if you run a composer update, it's very likely this fix will be overwritten.

2 likes
Highlandmind's avatar

If you use @sundaybk solution with

return $exception;

laravel's missing route handler will stop working.

1 like
dmeganoski@gmail.com's avatar

I see this is still getting attention, so for any of you that are still having issues with this, here is an updated version of the laravel/framework package that supports php7.

It has been updated to 4.2.19 despite the name.

https://github.com/jadz/laravel-framework-4.2.18-php7

You will need to simply add the following to your 'repositories' file to use this version instead

{
      "type": "git",
      "url": "https://github.com/jadz/laravel-framework-4.2.18-php7"
    }

Then, change the version of "laravel/framework" to "dev-master".

I have been using this in production for months with no issues.

jaahvicky's avatar

I think you were supposed to run composer install rather than composer update. Have a look at semantic versioning it will help you understand the difference between composer install and composer update.

khokhoni's avatar

The previous comments worked for me, thanks. I added the return statement to :

File name: vendor\laravel\framework\src\Illuminate\Exception\Handler.php Method name : callCustomHandlers

protected function callCustomHandlers($exception, $fromConsole = false) { return $exception; // add this line foreach ($this->handlers as $handler) { // If this exception handler does not handle the given exception, we will just // go the next one. A handler may type-hint an exception that it handles so // we can have more granularity on the error handling for the developer. if ( ! $this->handlesException($handler, $exception)) { continue; } elseif ($exception instanceof HttpExceptionInterface) { $code = $exception->getStatusCode(); }

........

b8700852's avatar

This solves the 'Whoops' error, but has the side-effect of getting not any error message displayed whenever an exception happens.

I solved this by adding the following right before the return line:

echo $exception;

Please or to participate in this conversation.