我已经扩展了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"
}
}
}
我解决了它:
"repositories":
[
{
"type": "vcs",
"url": "https://github.com/Leopandro/yii2-user"
}
],
"require":
{
"dektrium/yii2-user": "master",//master is name of my forked branch
}
如果您派生了一个要使用的包,请给它一个新名称!现在你必须维护的是你的项目(否则,你就不会分叉它)。
拥有一个新名称可以让你在没有冲突的情况下将其添加到Packagist,或者在项目中使用它的新名称。
在composer.json
:中,将您自己的存储库添加到项目中就像这样
"require": {
"your-new/package-name": "~1.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Leopandro/dektrium"
}
]
如果Composer反应混乱,可以通过删除供应商文件夹来解决,然后重试。
另一方面:如果你唯一想做的就是更改一两行不完全适合你的用例,那么拆分一个项目确实不是正确的方式。我无法评估您的更改的影响,但您应该始终尝试找到一个不包括派生他人代码的解决方案。
此外,您可以在回购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"
}
]
在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 更新