【发布时间】:2019-05-16 05:47:29
【问题描述】:
我目前有一个 laravel 5.8 实例在我的本地机器上运行,我将文件移到了在 Centos 上运行的暂存服务器上。我最近将那里的 PHP 版本更新到 7.3,它是 5.4 现在我正在尝试启动服务器并显示网页,但我一直收到一个奇怪的错误。
我已经重启了整个服务器。
我去了 /var/www/myproject/public_html/staging/app/Exceptions/Handler.php:50(虽然这是供应商文件)
public function report(\Exception $e)
{
if ($e instanceof \Exception) {
$debugSetting = Config::get('app.debug');
Config::set('app.debug', true); //<--- This is line 50
//echo "<pre>" . $e . "</pre>";
$data = ['content' => $e->getMessage(),'line' => $e->getLine(),'trace' => $e->getTraceAsString()];
Config::set('app.debug', $debugSetting);
}
return parent::report($e);
}
如果您熟悉 Laravel,您会知道 Config 是项目核心功能的一部分,并且它无法访问它意味着其他一些错误导致无法正确设置或实例化不正确。
我只是尝试运行 composer update 或 composer install 但这个错误也阻止了我。
我还检查了 httpd/ssl_error_log,它显示的错误几乎相同,如下所示
PHP Fatal error: Uncaught Error: Class 'Config' not found in /var/www/myproject/public_html/staging/app/Exceptions/Handler.php:50\nStack trace:\n#0 /var/www/myproject/public_html/staging/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(314): App\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))\n#1 /var/www/myproject/public_html/staging/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\\Foundation\\Http\\Kernel->reportException(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))\n#2 /var/www/myproject/public_html/staging/public/index.php(57): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))\n#3 {main}\n thrown in /var/www/myproject/public_html/staging/app/Exceptions/Handler.php on line 50
我的错误
PHP Fatal error: Uncaught Error: Class 'Config' not found in
/var/www/myflexca/public_html/staging/app/Exceptions/Handler.php:50
Stack trace:
#0
/var/www/myproject/public_html/staging/vendor/laravel/framework/src/Illuminat/
Foundation/Console/Kernel.php(367): App\Exceptions\Handle->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1
/var/www/myproject/public_html/staging/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(132):
Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /var/www/myproject/public_html/staging/artisan(35):
Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput),
Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 {main}
thrown in
/var/www/myproject/public_html/staging/app/Exceptions/Handler.php on line 50
解决方案
我通过更改解决了这个问题
use Config;
在顶部到
use Illuminate\Support\Facades\Config;
它之后只是出现了更多错误,但它超过了这个。
真正的问题
我的 Laravel 依赖项不是最新的。真正的解决方案是重新安装 Laravel 以获取依赖项。
composer global require laravel/installer
【问题讨论】:
-
我敢打赌,如果您查看
/var/www/myflexca/public_html/staging/app/Exceptions/Handler.php的第 50 行,您就会发现问题。 -
确保你运行
composer install。 -
@miken32 对不起,我这样做了,我会编辑帖子
-
您很可能遇到了不同的根错误。然后,您的异常处理程序在尝试管理第一个错误时会引发第二个错误。检查您的错误日志以了解以前的异常。