使symfony安装相同版本的依赖项

时间:2019-06-03 21:34:26

标签: php symfony composer-php

因此,我最近将我的symfony项目更新为4.3版本,由于它引起了问题,因此将其降级为4.2.9。 但是,尽管我付出了很多努力,并且选择了各种作曲家,但它仍在继续安装 它对4.3的依赖((树枝,安全性,yaml ...) 即使其composer.json文件清楚地表明它应该使用相同的版本。 我删除了供应商,清除了缓存,删除了composer.lock和symfony.lock使用了--no-cache选项,特别是将composer中的symfony版本精确地设置为4.2.9,但它始终安装了4.3,这有点令人沮丧。 如果我签出旧的composer.lock并进行安装,则可以运行,但是即使我在symfony的json中设置了4.2.9,更新仍将安装4.3。

有没有出路?谢谢

我正在使用

composer update --no-cache --dry-run

查看未实际安装的安装

这是我的composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-iconv": "*",
        "friendsofsymfony/jsrouting-bundle": "^2.3",
        "sensio/framework-extra-bundle": "^5.1",
        "symfony/console": "^4.0",
        "symfony/flex": "^1.0",
        "symfony/form": "^4.0",
        "symfony/framework-bundle": "4.2.9",
        "symfony/lts": "^4@dev",
        "symfony/monolog-bundle": "^3.3",
        "symfony/orm-pack": "^1.0",
        "symfony/security-bundle": "^4.1",
        "symfony/translation": "^4.0",
        "symfony/twig-bundle": "^4.0",
        "symfony/validator": "^4.0",
        "symfony/webpack-encore-pack": "^1.0",
        "symfony/yaml": "^4.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "sensiolabs/security-checker": "^5.0",
        "symfony/debug-bundle": "^4.1",
        "symfony/dotenv": "^4.0",
        "symfony/maker-bundle": "^1.9",
        "symfony/profiler-pack": "^1.0",
        "symfony/web-server-bundle": "^4.0"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
            "security-checker security:check": "script"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "4.2.9"
        }
    }
}

注意:我不是在谈论我自己的composer.json的依赖项,而是在symfony安装的依赖项中,例如http-foundation或http-kernel。

2 个答案:

答案 0 :(得分:0)

composer.lock它维护以前使用的确切版本。 'composer update'和'composer install'之间有区别

恢复composer.lock

git checkout -- composer.lock
rm -rf vendor 
composer install

答案 1 :(得分:0)

对于依赖性,您将^ 4.0指定为版本,这表示以4开头的最新版本。如果最新更新引起了问题,则应将这些约束条件更改为更具限制性的内容,例如您使用的确切版本之前(4.2.9)。然后运行composer update并应安装正确的版本。