Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 7 throws error 255 upgrading from laravel 6

I just tried to upgrade Laravel from v6 to v7, my php version is 7.3, i upgraded all dependencies as stated on laravel site, and removed conflicting packages, the upgrade seems to be completed but with the following error:

Generating optimized autoload files> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Fatal error:  Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in /var/www/html/virtuozzo-api/app/Exceptions/Handler.php on line 8
PHP Fatal error:  Uncaught ReflectionException: Class App\Exceptions\Handler does not exist in /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Container/Container.php:803
Stack trace:
#0 /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(803): ReflectionClass->__construct('App\\Exceptions\\...')
#1 /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(681): Illuminate\Container\Container->build('App\\Exceptions\\...')
#2 /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(787): Illuminate\Container\Container->resolve('App\\Exceptions\\...', Array, false)
#3 /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(265): Illuminate\Foundation\Application->resolve('App\\Exceptions\\...', Array, false)
#4 /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(799): Illuminate\Container\Container->Illuminate\Container\{cl in /var/www/html/virtuozzo-api/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 805
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

i have tried already deleting the vendor folder and installing again, also with composer dump autoload, and tried to clear laravel cache, but always get the same error.

like image 235
NaturalDevCR Avatar asked Mar 04 '20 14:03

NaturalDevCR


People also ask

How to upgrade from Laravel 6 to Laravel 7?

Upgrade Laravel 6.x to Laravel 7.x The Laravel 7.x Shift automates the upgrade of your Laravel application from Laravel 6.x to Laravel 7.x. Using the Laravel 7.x Shift to automatically upgrade your Laravel application has an estimated time savings of 1 hour. Laravel 7 has reached end of life.

What is the Laravel 7 shift?

The Laravel 7.x Shift automates the upgrade of your Laravel application from Laravel 6.x to Laravel 7.x. Using the Laravel 7.x Shift to automatically upgrade your Laravel application has an estimated time savings of 1 hour. Laravel 7 has reached end of life.

Are there any breaking changes in the Laravel framework?

We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application. Want to save time? You can use Laravel Shift to help automate your application upgrades. Laravel now requires PHP 8.0.2 or greater.

How to create 404 error page in Laravel 6?

You need to create blade file like 404.blade.php, 405.blade.php etc on errors (resources/view.errors) directory in laravel 6. you can see i created 404 blade file and check it on your project. Almost we are using theme for front-end or backend side and we always looking for set 404, 500 or 505 error page design from there that we used for project.


1 Answers

In your app/Exceptions/Handler.php file: replace the Exception typehints with Throwable typehints.

As mentioned in the Upgrade guide.

like image 156
Jerodev Avatar answered Oct 13 '22 01:10

Jerodev