I’m trying to use my forked version of yiisoft/yii2 in an installation of yii2-app-advanced.
I’ve followed this wiki.
I have created a branch named custom
and pushed it to my yii2 fork.
In the composer.json of my fork I have the following (does it matter?):
...
"extra": {
"branch-alias": {
"dev-custom": "2.0.x-dev"
}
...
Then in my yii2-app-advanced
installation I have the following composer.json
:
{
"name": "yiisoft/yii2-app-advanced",
...
"minimum-stability": "stable",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/david-it/yii2"
}
],
"require": {
"php": ">=5.6.0",
"yiisoft/yii2": "dev-custom",
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
"yiisoft/yii2-bootstrap4": "~2.0.6"
},
...
}
When I run composer update
I get the following error:
Problem 1
- The requested package yiisoft/yii2 dev-custom exists as yiisoft/yii2[2.0.0, 2.0.0-alpha, 2.0.0-beta, 2.0.0-rc, 2.0.1, 2.0.10, 2.0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.12.1, 2.0.12.2, 2.0.13, 2.0.13.1, 2.0.13.2, 2.0.13.3, 2.0.14, 2.0.14.1, 2.0.14.2, 2.0.15, 2.0.15.1, 2.0.16, 2.0.16.1, 2.0.17, 2.0.18, 2.0.19, 2.0.2, 2.0.20, 2.0.21, 2.0.22, 2.0.23, 2.0.24, 2.0.25, 2.0.26, 2.0.27, 2.0.28, 2.0.29, 2.0.3, 2.0.30, 2.0.31, 2.0.32, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.x-dev, 3.0.x-dev, dev-master, 2.0.x-dev] but these are rejected by your constraint.
The command composer why-not yiisoft/yii2 dev-custom
(if it is any useful here) shows this:
yiisoft/yii2-bootstrap4 2.0.8 requires yiisoft/yii2 (~2.0)
yiisoft/yii2-debug 2.1.13 requires yiisoft/yii2 (~2.0.13)
yiisoft/yii2-faker 2.0.4 requires yiisoft/yii2 (~2.0.0)
yiisoft/yii2-gii 2.1.4 requires yiisoft/yii2 (~2.0.14)
yiisoft/yii2-swiftmailer 2.1.2 requires yiisoft/yii2 (>=2.0.4)
I’m not sure what I am missing. I’ve looked around including this and this questions but with no luck.
EDIT 1
Composer 1.9.3 (2020-02-04 12:58:49) with PHP 7.2.24-0ubuntu0.18.04.3 on Linux / 4.15.0-91-generic
EDIT 2
Selecting dev-master
as required works but the original files are downloaded (not the ones in the fork).
"require": {
...
"yiisoft/yii2": "dev-master",
...
}
I also tried all the tips from this answer with no luck.
2
Answers
After long hours of trial-and-error I've found two working solutions.
Solution 1 (With the help of Yii2 forum)
The branch apparently is considered "unstable", so you need to specify
@dev
to make composer work fine:Solution 2
In the
composer.json
of my fork I've added an alias pointing to the branch:Where
n
is just number (it should be unique among the versions available, I guess).Then in the
composer.json
of my project I used"yiisoft/yii2": "2.0.n.x-dev"
.I'm not quite sure why I have to use
"2.0.n.x-dev"
instead of"2.0.n-dev"
. A possible explanation is here.At the moment, you have the
custom
branch. You need to create a branch nameddev-custom
in this situation, use the same branch name inrequire
section of your composer.json file.