Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

php - syntax error, unexpected ')' after Laravel update

I have updated my laravel project to "laravel/framework": "^8.12" from laravel 5.7, but after updating when I run composer dump-autoload it returns this error

Generating optimized autoload files> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In TestDatabases.php line 148:

  syntax error, unexpected ')'

here is my composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "intervention/image": "^2.5",
        "laravel/framework": "^8.12",
        "laravel/sanctum": "^2.8",
        "laravel/tinker": "^2.5",
        "laravel/ui": "^2.0",
        "barryvdh/laravel-dompdf": "^0.8.3",
        "nao-pon/flysystem-google-drive": "~1.1",
        "spatie/laravel-backup": "^6.14"
    },
    "require-dev": {
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        },
        "files": [
            "app/Helpers/helpers.php",
            "app/Helpers/agent_helper.php",
            "app/Helpers/user-helpers.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}


how to solve this error?

question from:https://stackoverflow.com/questions/66061548/syntax-error-unexpected-after-laravel-update

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to upgrade your PHP installation to at least version 7.3 to resolve the issue.

PHP 7.2 is EOL (end of life) since 30 Nov 2020!

As already stated in the comments:

Laravel 8 requires php 7.3 or higher

Larvel 8 has the following PHP version constraint in composer.json:

"require": {
  "php": "^7.3|^8.0"
}

Do NOT run composer with the --ignore-platform-reqs flag unless you have a (very rare) valid reason to do so.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...