suchen

Heim  >  Fragen und Antworten  >  Hauptteil

Laravel 9 Composer-Syntaxfehler, unerwartete Markierung „)“

Nachdem ich composer update in meinem Laravel 9-Projekt ausgeführt habe, ist die folgende Fehlermeldung aufgetreten:

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

Es scheint, dass das Update abgeschlossen wurde, aber etwas ist schief gelaufen und jetzt wird in der Konsole syntax 错误,意外标记“)” Finder.php 上的错误:588 angezeigt.

Ich habe die Datei überprüft und sie sieht korrekt aus.

Wenn ich das Projekt im Browser öffne, erhalte ich diese Fehlermeldung:

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

Ich habe außerdem alle Caches im bootstrap/cahce/storage/framework/cache/data/storage/framework/sessions/storage/framework/views/-Ordner geleert.

Ich verwende PHP Version 8.0.16.

Composer-Version 2.0.12 2021-04-01 10:14:59.

Irgendeine Idee, wie man dieses Problem lösen kann?

P粉940538947P粉940538947247 Tage vor571

Antworte allen(2)Ich werde antworten

  • P粉510127741

    P粉5101277412024-03-26 16:33:49

    要继续使用 php 8.0,请将这些条目添加到您的composer.json

    "require": {
            ...
            "symfony/console": "6.0.*",
            "symfony/error-handler": "6.0.*",
            "symfony/finder": "6.0.*",
            "symfony/http-foundation": "6.0.*",
            "symfony/http-kernel": "6.0.*",
            "symfony/mailer": "6.0.*",
            "symfony/mime": "6.0.*",
            "symfony/process": "6.0.*",
            "symfony/routing": "6.0.*",
            "symfony/var-dumper": "6.0.*",
            "symfony/event-dispatcher": "6.0.*",
            "symfony/string": "6.0.*",
            "symfony/translation": "6.0.*",
            "symfony/translation-contracts": "3.0.*",
            "symfony/service-contracts": "3.0.*",
            "symfony/event-dispatcher-contracts": "3.0.*",
            "symfony/deprecation-contracts": "3.0.*",
            ...
        }

    为我使用 php 8.0 和 Laravel 9。

    Antwort
    0
  • P粉773659687

    P粉7736596872024-03-26 15:53:08

    我找到了一个解决方案:

    1. 升级到 PHP 8.1
    2. 运行docker pullcomposer以升级最新版本的composer(从2.0到2.2)
    3. 在 Docker 容器中运行 composer update

    Antwort
    0
  • StornierenAntwort