如何将forked包添加到composer.json文件中

时间:2015-12-06 21:52:24

标签: php yii composer-php

我已经扩展了dektrium包并将此包上传到我的GitHub https://github.com/Leopandro/dektrium。我想将此包添加到composer.json中。

我已尝试将此行"dektrium/yii2-user": "0.9.*@dev"更改为"Leopandro/dektrium/yii2-user"但未发生任何变化。

我的composer.json

    {
    "name": "yiisoft/yii2-app-basic",
    "description": "Yii 2 Basic Project Template",
    "keywords": ["yii2", "framework", "basic", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "dev",
    "prefer-stable" : true,
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": ">=2.0.5",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "dektrium/yii2-user": "0.9.*@dev",
        "execut/yii2-widget-bootstraptreeview": "dev-master",
        "2amigos/yii2-file-upload-widget": "~1.0",
        "kartik-v/yii2-widget-select2": "@dev",
        "paulzi/yii2-adjacency-list": "^1.0"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    },
    "config": {
        "process-timeout": 1800
    },
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ],
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        },
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}

4 个答案:

答案 0 :(得分:1)

我解决了它:

"repositories":
    [
        {
            "type": "vcs",
            "url": "https://github.com/Leopandro/yii2-user"
        }
    ],
"require": 
  {
      "dektrium/yii2-user": "master",//master is name of my forked branch
  }

答案 1 :(得分:0)

如果您分叉要使用的包,请为其指定一个新名称!现在你必须维护你的项目(否则,你不会分叉它)。

使用新名称可以将其添加到Packagist而不会发生冲突,或者只是在项目中使用它的新名称。

将自己的存储库添加到项目中就像在"require": { "your-new/package-name": "~1.0" }, "repositories": [ { "type": "vcs", "url": "https://github.com/Leopandro/dektrium" } ]

中一样
* {font-family: myFont}

如果Composer反应混乱,可以通过删除供应商文件夹解决,然后再试一次。

另一方面:如果您想要做的唯一事情就是更改一条或两条不完全适合您的用例的行,那么分叉项目确实不是正确的方法。我无法评估您的更改的影响,但您应该总是尝试找到一个不包括分享其他人的解决方案。代码。

答案 2 :(得分:0)

此外,您可以在仓库some-fixes-and-enhancements中创建早午餐,并将此早午餐名称用作带有dev-前缀的软件包版本:

"require": {
    "dektrium/yii2-user": "dev-some-fixes-and-enhancements", // your branch name here
},
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/Leopandro/yii2-user"
    }
]

答案 3 :(得分:-2)

composer.json添加dektrium/yii2-user分叉的存储库部分,如下所示:

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "dektrium/yii2-user",
            "version": "dev-master",
            "source": {
                "url": "https://github.com/Leopandro/dektrium/tree/master/yii2-user",
                "type": "git",
                "reference": "master"
            },
            "autoload": {
                "classmap": [""]
            }
        }
    }
],

您需要将此软件包的require部分更改为dev-master或您在上述存储库部分中设置的版本。

"require": {
    "dektrium/yii2-user": "dev-master"
},

运行composer updade -vvv以查看它从您的GitHub fork更新