Reputation: 103
I am getting this problem: http://pastebin.com/B5MKqD0T
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Illuminate\Exception\WhoopsDisplayer::display() must be an instance of Exception, instance of ParseError given
But I have no clue how to fix it, I am new to laravel and composer etc.
I am using laravel 4.0 (because I'm following and old tutorial of my friend)
Upvotes: 8
Views: 7620
Reputation: 1666
Laravel released 4.2.20 that resolved this issue. https://twitter.com/laravelphp/status/791302938027184128
Upvotes: 1
Reputation: 93
There's another approach where you can wrap the Laravel exception handler with your own, convert the new Error type to an Exception instance before passing back to Laravel.
Create the below class somewhere in your application:
namespace Some\Namespace;
use Error;
use Exception;
class ErrorWrapper
{
private static $previousExceptionHandler;
public static function setPreviousExceptionHandler($previousExceptionHandler)
{
self::$previousExceptionHandler = $previousExceptionHandler;
}
public static function handleException($error)
{
if (!self::$previousExceptionHandler) {
return;
}
$callback = self::$previousExceptionHandler;
if ($error instanceof Error) {
$callback(new Exception($error->getMessage(), $error->getCode()));
}
else {
$callback($error);
}
}
}
At the start of config/app.php, you can then register the wrapper class as the default error handler:
$existing = set_exception_handler(
['Some\Namespace\ErrorWrapper', 'handleException']);
ErrorWrapper::setPreviousExceptionHandler( $existing );
Upvotes: 1
Reputation: 8190
Found a nice work-around to disable the laravel error handler. Add this to the top of your app/config/local/app.php (right before the return array(...):
set_error_handler(null);
set_exception_handler(null);
Upvotes: 8
Reputation: 54379
ParseError
was introduced in PHP 7. In other hand you're using Laravel 4 which has no PHP7 support.
Laravel 5.1 is the first version of Laravel to support PHP 7.
So, there's 2 solutions:
Read more about throwable exceptions in PHP7: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/
Upvotes: 17