Behzadsh
Behzadsh

Reputation: 870

laravel 5 show blank page on server error (and no laravel log), running with hhvm and nginx

I followed Fideloper post about running laravel with hhvm, step by step. There are two projects hosted on my server, one is my blog which is based on wardrobe (laravel 4.1), and another project with laravel 5.

My blog has no issue with server errors and laravel log file; But the other project cannot create log files, and it won't show error page because of that.

I double checked storage folder permission. It is 777.

When I run php artisan serve (native php, not hhvm) and browse to it, the error page showed up, and log file was created. So something is wrong with hhvm I think.

How can I fix blank page, when running laravel 5 with hhvm, and an error occurred? How can I bring back the error page (or whoops page)

P.S. I have read related question like this and still have the problem.

P.S.S. If any information needed ask me and I will update the question.

Upvotes: 1

Views: 4680

Answers (2)

prograhammer
prograhammer

Reputation: 20620

I suffered the same problem when I installed Laravel Homestead with HHVM. If you enter some random junk like sdfkjl into your routes file you'll get a blank page (however, if add a semi-colon sdfkjl; you get error output). The errors are being logged at /var/log/hhvm/error.log but they don't go to the browser, instead you just get a blank page. It appears this is intentional behavior for HHVM. It also appears Laravel tries to handle these but doesn't catch some of the fatals sent by HHVM. Thanks to clues from this github issue I decided to make some slight changes to Laravel's Foundation\Bootstrap\HandleExceptions.php to see if I could get it to catch all of these fatals:

First, update your /etc/hhvm/php.ini and add these settings:

hhvm.server.implicit_flush = true
hhvm.error_handling.call_user_handler_on_fatals = true

Before modifying a package source, let's remove the vendor\compiled.php with this artisan command:

$ php artisan clear-compiled

And let's set the environment sessons to array:

in your .env

SESSION_DRIVER=array

(You may also need to clear all the random-looking session files in storage/framework/sessions)

Now any changes we make to the Laravel package source will immediately reflect. Let's update a few things in the HandleExceptions class:

in vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php

// **** Add this to hold fatal error
protected static $fatalError = null;

...

public function handleError($level, $message, $file = '', $line = 0, $context = array())
{

   // **** Add this, loads fatal error
   if ($level & (1 << 24)) {
        self::$fatalError = array(
            'message' => $message,
            'type' => $level,
            'file' => $file,
            'line' => $line
        );
    }   

    if (error_reporting() & $level)
    {
        throw new ErrorException($message, 0, $level, $file, $line);
    }
} 

...   

// *** Update this function so it can handle the fatal
public function handleShutdown()
{
    $error = error_get_last();

    if(self::$fatalError){
        $error = self::$fatalError;
    }

    if ( ! is_null($error) && $this->isFatal($error['type']))
    {
        $this->handleException($this->fatalExceptionFromError($error, 0));
    }
}

...

protected function isFatal($type)
{
    // *** Add type 16777217 that HVVM returns for fatal
    return in_array($type, [16777217, E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]);
}

...

Now type the random junk (no semi-colon) in your routes folder and you'll see the fatal display. I have now reported this issue to Taylor on the Laravel github. If you are in Lumen, I've got a solution here that will work until Lumen gets fixed as well.

Upvotes: 3

TIJ
TIJ

Reputation: 3181

I also got the same issue. Give 755 permission to entire laravel project it's work for me

anyway you can check hhvm error log, run

$tail -n 50 -f /var/log/hhvm/error.log

Upvotes: -1

Related Questions