laravel 在不同的PHP版本中运行“composer update

az31mfrm  于 2023-03-19  发布在  PHP
关注(0)|答案(2)|浏览(127)

我正在进行一个Laravel项目。我的composer.json文件如下所示。

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "barryvdh/laravel-dompdf": "0.8.6",
        "doctrine/dbal": "^2.10",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0",
        "maatwebsite/excel": "^3.1",
        "phpoffice/phpspreadsheet": "^1.21",
        "propaganistas/laravel-phone": "4.2.3",
        "spatie/db-dumper": "^2.15",
        "timehunter/laravel-google-recaptcha-v3": "~2.2.16",
        "webup/laravel-sendinblue": "~2.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^7.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
      "repositories": {
        "packagist.org": {
          "type": "composer",
          "url": "https://packagist.org"
        }
      },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "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"
        ]
    }
}

最初我使用的是PHP 8.1。我得到下面的错误。

Problem 1
    - Root composer.json requires php ^7.1.3 but your php version (8.1.10) does not satisfy that requirement.
  Problem 2
    - laravel/framework[v5.8.0, ..., 5.8.x-dev] require php ^7.1.3 -> your php version (8.1.10) does not satisfy that requirement.
    - Root composer.json requires laravel/framework 5.8.* -> satisfiable by laravel/framework[v5.8.0, ..., 5.8.x-dev].

之后,我改变了我的PHP版本为7.0。然后我得到下面的错误,而我正在运行composer update命令。

Composer 2.3.0 dropped support for PHP <7.2.5 and you are running 7.0.33-57+ubuntu18.04.1+deb.sury.org+1, please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.

如何在此项目中运行composer update命令?

lkaoscv7

lkaoscv71#

我认为您需要安装php^7.1.3,安装后,您需要更改php^7.1.3的环境路径后,运行命令

62lalag4

62lalag42#

是的,您需要安装xampp 7.1.30。在此之前,请卸载旧的xampp。并删除c盘中的xampp文件。

相关问题