使用Composer命令克隆Composer配置

时间:2017-12-13 06:45:24

标签: composer-php

我有一个已添加Composer的项目。我最近发现生产包很久以前就更新了,而没有将composer.jsoncomposer.lock文件提交给Git。

我已经在Git的最新版本中建立了一个全新的开发和测试环境,我不知道的是,它使用了某些软件包的错误版本。

我手动require d所有确切的版本都与Production相匹配,composer.lock文件现在差不多完全相同。

我必须复制完整的Composer版本(在beta1和beta2之间)才能实现这一目标。

这些是我现在想要以diff格式进行的更改,其中( - )是开发/测试,(+)是生产:

    {
        "name": "doctrine/doctrine-migrations-bundle",
        "version": "dev-master",
        "source": {
            "type": "git",
            "url": "https://github.com/doctrine/DoctrineMigrationsBundle.git",
            "reference": "c0a2f5d069e56e2ac7a42719dfda63fd996a39ed"
        },
        "dist": {
            "type": "zip",
-           "url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/d78e19f96b54aed55aceedcdddd0fdc994b1010b",
+           "url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/c0a2f5d069e56e2ac7a42719dfda63fd996a39ed",
            "reference": "c0a2f5d069e56e2ac7a42719dfda63fd996a39ed",
            "shasum": ""
        },
        "require": {
            "doctrine/doctrine-bundle": "~1.0",
            "doctrine/migrations": "^1.1",
            "php": ">=5.4.0",
-           "symfony/framework-bundle": "~2.7|~3.3|~4.0"
+           "symfony/framework-bundle": "~2.3|~3.0"
        },
+       "require-dev": {
+           "phpunit/phpunit": "~4.8"
+       },
        "type": "symfony-bundle",
        "extra": {
            "branch-alias": {
                "dev-master": "1.1-dev"
            }
        },
...
    {
        "name": "doctrine/migrations",
        "version": "dev-master",
        "source": {
            "type": "git",
            "url": "https://github.com/doctrine/migrations.git",
            "reference": "0d0ff5da10c5d30846da32060bd9e357abf70a05"
        },
        "dist": {
            "type": "zip",
-           "url": "https://api.github.com/repos/doctrine/migrations/zipball/488fb6994839eb1e10b823532888ea0ff9d19846",
+           "url": "https://api.github.com/repos/doctrine/migrations/zipball/0d0ff5da10c5d30846da32060bd9e357abf70a05",
            "reference": "0d0ff5da10c5d30846da32060bd9e357abf70a05",
            "shasum": ""
        },
        "require": {
            "doctrine/dbal": "~2.2",
            "ocramius/proxy-manager": "^1.0|^2.0",
            "php": "^5.5|^7.0",
            "symfony/console": "~2.3|~3.0",
            "symfony/yaml": "~2.3|~3.0"
        },
        "require-dev": {
            "doctrine/coding-standard": "dev-master",
            "doctrine/orm": "2.*",
            "jdorn/sql-formatter": "~1.1",
            "johnkary/phpunit-speedtrap": "~1.0@dev",
            "mockery/mockery": "^0.9.4",
            "phpunit/phpunit": "~4.7",
            "satooshi/php-coveralls": "0.6.*"
        },
        "suggest": {
            "jdorn/sql-formatter": "Allows to generate formatted SQL with the diff command."
        },
        "bin": [
            "bin/doctrine-migrations"
        ],
        "type": "library",
        "extra": {
            "branch-alias": {
-               "dev-master": "v1.4.x-dev"
+               "dev-master": "v1.5.x-dev"
            }
        },
...
    {
        "name": "knplabs/knp-snappy-bundle",
        "version": "dev-master",
        "source": {
            "type": "git",
            "url": "https://github.com/KnpLabs/KnpSnappyBundle.git",
            "reference": "ead0b44c6a9a96c1817710cd854665ee755afe04"
        },
        "dist": {
            "type": "zip",
-           "url": "https://api.github.com/repos/KnpLabs/KnpSnappyBundle/zipball/f7c2541008525bb621a0bd492e1d83a6d2b48adf",
+           "url": "https://api.github.com/repos/KnpLabs/KnpSnappyBundle/zipball/ead0b44c6a9a96c1817710cd854665ee755afe04",
            "reference": "ead0b44c6a9a96c1817710cd854665ee755afe04",
            "shasum": ""
        },
        "require": {
            "knplabs/knp-snappy": "~0.1",
            "php": ">=5.3.2",
            "symfony/finder": "~2.3|~3.0",
            "symfony/framework-bundle": "~2.3|~3.0",
            "symfony/validator": "~2.3|~3.0"
        },
        "type": "symfony-bundle",
        "extra": {
            "branch-alias": {
                "dev-master": "1.5.x-dev"
            }
        },

我可以使用哪些Composer命令来使两个文件完全匹配,从而可能在所有环境中具有完全相同的包?如果某些行没有区别(例如确切的Git URL),我很乐意手动复制这些行。

1 个答案:

答案 0 :(得分:0)

要匹配composer.lock中使用的包的确切版本,您可能需要在composer.json中使用确切的提交哈希:

{
    "require": {
        "monolog/monolog": "dev-master#2eb0c0978d290a1c45346a1955188929cb4e5db7"
    }
}