So there are a few threads on this but none with exactly the same issue. Basically I upgraded to php 5.4 from 5.1 and php 7 from 5.6 and I am now getting this error message.
PHP Fatal error: Uncaught Error: Class name must be a valid object or a string in /var/www/dev1/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:96
The reason this seems weird to me is the error is in the actual laravel files not in my app / something I have edited. This error happens when I run composer update or whenever I try and visit any of my webpages. Below is a full dump from composer update, any ideas?
[root@dev1 dev1]# composer update
> php artisan clear-compiled
PHP Fatal error: Uncaught Error: Class name must be a valid object or a string in /var/www/dev1/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:96
Stack trace:
#0 [internal function]: Illuminate\Foundation\Exceptions\Handler->Illuminate\Foundation\Exceptions\{closure}(0, 'Symfony\\Compone...')
#1 /var/www/dev1/bootstrap/cache/compiled.php(6207): call_user_func(Object(Closure), 0, 'Symfony\\Compone...')
#2 /var/www/dev1/bootstrap/cache/compiled.php(12223): Illuminate\Support\Arr::first(Array, Object(Closure), NULL)
#3 /var/www/dev1/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(97): Illuminate\Support\Collection->first(Object(Closure))
#4 /var/www/dev1/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(61): Illuminate\Foundation\Exceptions\Handler->shouldntReport(Object(ReflectionException))
#5 /var/www/dev1/app/Exceptions/Handler.php(33): Illuminate\Foundation\Exceptions\Handler->report(Object(ReflectionException))
#6 /var/www/dev1/vendor/laravel/fram in /var/www/dev1/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php on line 96
Script php artisan clear-compiled handling the pre-update-cmd event returned with error code 255
Laravel 8 requires PHP 7.3+ or above so you need this version or the latest version of PHP installed on your system.
Laravel 9.x requires a minimum PHP version of 8.0.
I've got a similar error when upgrading to Laravel 5.4. The problem is that Laravel is still loading bootstrap/cache/compiled.php
(even though it says it's not used by the framework anymore). Removing the file will solve your issue.
From the docs:
If it exists, you may delete the bootstrap/cache/compiled.php file. It is no longer used by the framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With