簡體   English   中英

Laravel 6:尚未設置外觀根

[英]Laravel 6 : A facade root has not been set

我已將我的網站從 Laravel 5.8 遷移到 Laravel 6,在 Composer更新后,我在網站上出現此錯誤,並且僅使用一個命令php artisan

PHP Fatal error:  Uncaught RuntimeException: A facade root has not been set. in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:242
Stack trace:
#0 /var/www/html/app/Exceptions/Handler.php(48): Illuminate\Support\Facades\Facade::__callStatic('check', Array)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(376): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(141): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 /var/www/html/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 {main}
  thrown in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 242

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:242
Stack trace:
#0 /var/www/html/app/Exceptions/Handler.php(48): Illuminate\Support\Facades\Facade::__callStatic('check', Array)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(376): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(141): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 /var/www/html/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 {main}
  thrown in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 242 

我采用了一個新的 Laravel 6 文件config\\app.php和一個新的.env但總是這個錯誤......

我該如何解決?

我知道,答案有點晚了 :) 但我仍然相信它可以幫助遇到此問題的其他人。

Str::slug()替換所有str_slug()方法解決了這個問題。 就我而言,我在config/cache.phpconfig/session.php文件中找到了舊助手。

最后我找到了一個解決方案,我復制了一個 Laravel 6 配置文件: config/session.php並且它的工作原理。

讓我們嘗試一下:

導航至bootstrap / app.php。 取消注釋以下行(注釋通常是//,將其刪除)。

$app->withFacades();

所以代替

//$app->withFacades();

這將是

$app->withFacades();

我收到了這些錯誤 - 我自己的錯 - 我正在將我的 Laravel 應用程序文件移動到一個子目錄中,看起來像app.php以及我的/config/目錄中缺少其他一些文件:

cache.php
cors.php
filesystems.php
hashing.php
logging.php
mail.php
services.php
session.php
view.php

應該:

app.php
auth.php
broadcasting.php
cache.php
cors.php
database.php
filesystems.php
hashing.php
logging.php
mail.php
queue.php
services.php
session.php
view.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM