Laravel Masters Migration Walkthrough

I get this problem: http://pastebin.com/B5MKqD0T

PHP Fatal error: Uncaught TypeError: argument 1 passed Illuminate \ Exception \ WhoopsDisplayer :: display () must be an exception exception, an instance of ParseError specified

But I have no idea how to fix this, I am new to laravel and composer etc.

I am using laravel 4.0 (because I follow and my friendโ€™s old tutorial)

+7
php laravel migrate composer-php artisan
source share
4 answers

ParseError was introduced in PHP 7. In the other hand, you are using Laravel 4, which does not have PHP7 support.

Laravel 5.1 is the first version of Laravel to support PHP 7.

So there are 2 solutions:

  • upgrade Laravel to> = 5.1 (highly recommend this!)
  • lower PHP to 5. *

More on throwing exceptions in PHP7: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/

+16
source share

A nice workaround was found to disable the laravel error handler. Add this to the top of your application /config/local/app.php (right before the returned array (...):

 set_error_handler(null); set_exception_handler(null); 
+5
source share

Another approach in which you can wrap your Laravel exception handler with your own is to convert the new type of error to an Exception instance before moving on to Laravel.

Create a class below 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 beginning of config / app.php, you can register the wrapper class as the default error handler:

 $existing = set_exception_handler( ['Some\Namespace\ErrorWrapper', 'handleException']); ErrorWrapper::setPreviousExceptionHandler( $existing ); 
0
source share

Laravel released 4.2.20 which solved this problem. https://twitter.com/laravelphp/status/791302938027184128

0
source share

All Articles