在我的 Laravel 9 專案中執行 composer update
後,我遇到了以下錯誤訊息:
Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 0 installs, 1 update, 1 removal - Downloading fruitcake/laravel-cors (v3.0.0) - Removing asm89/stack-cors (v2.1.1) - Upgrading fruitcake/laravel-cors (v2.2.0 => v3.0.0): Extracting archive 77 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi In Finder.php line 588: syntax error, unexpected token ")" Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
似乎更新已完成,但出了點問題,現在在控制台中我收到 syntax 錯誤,意外標記“)”
Finder.php 上的錯誤:588
。
我檢查了這個文件,它看起來是正確的。
當我在瀏覽器中開啟專案時,出現此錯誤:
Fatal error: Uncaught RuntimeException: A facade root has not been set. in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:334 Stack trace: #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php(18): Illuminate\Support\Facades\Facade::__callStatic('replaceNamespac...', Array) #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(626): Illuminate\Foundation\Exceptions\RegisterErrorViewPaths->__invoke() #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(607): Illuminate\Foundation\Exceptions\Handler->registerErrorViewPaths() #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(538): Illuminate\Foundation\Exceptions\Handler->renderHttpException(Object(Symfony\Component\HttpKernel\Exception\HttpException)) #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(444): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(Symfony\Component\HttpKernel\Exception\HttpException)) #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(364): Illuminate\Foundation\Exceptions\Handler->renderExceptionResponse(Object(Illuminate\Http\Request), Object(ParseError)) #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(427): Illuminate\Foundation\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ParseError)) #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(115): Illuminate\Foundation\Http\Kernel->renderException(Object(Illuminate\Http\Request), Object(ParseError)) #8 /var/www/html/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #9 {main} thrown in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 334
我也清除了bootstrap/cahce/
和storage/framework/cache/data/
、storage/framework/sessions/
、storage /framework/views/
資料夾中的所有快取。
我使用 PHP 版本 8.0.16。
Composer 版本 2.0.12 2021-04-01 10:14:59。
知道如何解決這個問題嗎?
要繼續使用 php 8.0,請將這些項目新增到您的composer.json
為我使用 php 8.0 和 Laravel 9。
我找到了一個解決方案:
docker pullcomposer
以升級最新版本的composer(從2.0到2.2)composer update