使用Laravel 5.4和更新版本进行作曲家更新PHP 7"类名必须是有效对象或字符串"

时间:2017-03-10 21:06:10

标签: laravel composer-php php-7 laravel-5.4 php-7.1

因此,有一些线程,但没有完全相同的问题。基本上我从5.1升级到php 5.4,从5.6升级到php 7,我现在收到此错误消息。

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

这对我来说很奇怪的原因是错误是在我的app /我编辑过的实际laravel文件中。当我运行composer update或每次尝试访问我的任何网页时,都会发生此错误。以下是作曲家更新的完整转储,任何想法?

[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

2 个答案:

答案 0 :(得分:18)

升级到Laravel 5.4时,我遇到了类似的错误。问题是Laravel仍在加载bootstrap/cache/compiled.php(尽管它说它不再被框架使用)。删除文件将解决您的问题。

From the docs

  

如果存在,您可以删除bootstrap / cache / compiled.php文件。它不再被框架使用。

答案 1 :(得分:-1)

php artisan cache:clear

php artisan clear-compiled 

sudo composer dump-autoload