【问题标题】:Composer install using Homestead gives error "Your requirements could not be resolved to an installable set of packages"使用 Homestead 安装 Composer 时出现错误“您的要求无法解析为可安装的软件包集”
【发布时间】:2017-12-07 20:55:58
【问题描述】:

我正在尝试使用以下命令安装我的作曲家包:

composer install --no-dev --no-scripts

composer.json 文件看起来像这样(它与标准的 Laravel 作曲家文件非常相似):

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "doctrine/dbal": "^2.5",
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "symfony/css-selector": "2.8.*|3.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*",
        "laravel/homestead": "^5.2",
        "barryvdh/laravel-ide-helper": "^2.3"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

但是,当我尝试将它安装在我的生产机器上(运行 PHP 版本 v5.5.9 时,我收到以下错误:

您的需求无法解析为一组可安装的软件包。

  Problem 1
    - laravel/homestead v5.4.0 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead v5.3.2 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead v5.3.1 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead v5.3.0 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead v5.2.4 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead v5.2.1 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead v5.2.0 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead 5.2.3 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - laravel/homestead 5.2.2 requires php ^5.6 || ^7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
    - Installation request for laravel/homestead ^5.2 -> satisfiable by laravel/homestead[5.2.2, 5.2.3, v5.2.0, v5.2.1, v5.2.4, v5.3.0, v5.3.1, v5.3.2, v5.4.0].

所以我的问题如下:

  • 当我说--no-dev 并且 homestead 是一个开发包时,为什么还要安装 homestead?
  • 如果我确实想在我的生产机器上安装 Homestead,我该如何解决上述问题?

【问题讨论】:

    标签: laravel composer-php homestead


    【解决方案1】:

    --no-dev 不应安装开发依赖项。检查您的生产构建脚本(或您用于在生产中运行它的任何内容),确实添加了 --no-dev

    对于您问题的第二部分,您可以通过将laravel/homestead 包版本更改为~4.04.0.5 来避免错误,以使其与您的php版本兼容。

    【讨论】:

    • 我了解不应安装开发依赖项。那么为什么会这样呢?我认为没有理由这样做,我还添加了--no-scripts
    • 我用完全相同的composer.json 进行了测试,它没有安装任何开发依赖项。即使在开发机器上,您是否也会收到此错误?
    • 不在开发机器上,因为我在开发机器上使用的是更高版本的 PHP。
    猜你喜欢
    • 1970-01-01
    • 2021-10-28
    • 2016-09-05
    • 1970-01-01
    • 2016-11-20
    • 1970-01-01
    • 2016-03-13
    • 2018-01-11
    • 2014-06-10
    相关资源
    最近更新 更多