Composer: use fork of yiisoft/yii2 into installation of yii2-app-advanced

I’m trying to use my fork of yiisoft/yii2 into an installation of yii2-app-advanced.

I’ve created a branch custom in my fork following this wiki.

I cannot manage composer to use my fork without braking the dependencies required by other packages of yii2-app-advanced.

My composer.json:

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Project Template",
    "keywords": ["yii2", "framework", "advanced", "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": "stable",
    "require": {
        "php": ">=5.6.0",
        "yiisoft/yii2": "dev-custom",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
        "yiisoft/yii2-bootstrap4": "~2.0.6"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.1.0",
        "yiisoft/yii2-gii": "~2.1.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/codeception": "^4.0",
        "codeception/module-asserts": "^1.0",
        "codeception/module-yii2": "^1.0",
        "codeception/module-filesystem": "^1.0",
        "codeception/verify": "~0.5.0 || ~1.1.0",
        "symfony/browser-kit": ">=2.7 <=4.2.4"
    },
    "config": {
        "process-timeout": 1800,
        "fxp-asset": {
            "enabled": false
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        },
        {
            "type": "vcs",
            "url": "https://github.com/david-it/yii2.git"
        }
    ]
}

When I run composer update I get the following error:

Your requirements could not be resolved to an installable set of packages.

      Problem 1
        - The requested package yiisoft/yii2 dev-custom exists as yiisoft/yii2[2.0.0, ..., dev-master, 2.0.x-dev] but these are rejected by your constraint.

Instead of using "yiisoft/yii2": "dev-custom" I tried to use "yiisoft/yii2-dev": "dev-custom" since yiisoft/yii2-dev is the name of the package yiisoft/yii2. In that case I get several errors because other packages depends on yiisoft/yii2:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Removal request for yiisoft/yii2 == 2.0.9999999.9999999-dev
    - yiisoft/yii2-gii 2.1.4 requires yiisoft/yii2 ~2.0.14 -> satisfiable by yiisoft/yii2[2.0.x-dev, ,,,, 2.0.32].

What is the right way to test and use custom forks of yiisoft/yii2?

The issue is about using a branch. It is considered an unstable version and that doesn’t match "minimum-stability": "stable". There are two ways fixing it:

  1. Tag a version in your fork.
  2. Use "yiisoft/yii2": "dev-custom@dev".

I’d try second way first.

btw., why do you need a fork?

I’m using a fork because I want to learn how to handle the test and development using forks.

A general procedure is suggested in this workflow but in real practice I was missing how to include my modifications in a complete project.

I have found a workaround for a small issue that I noticed (in yiisoft/yii2) and I’m trying to find a way to test it properly.

Regarding the answer, I tried to use "yiisoft/yii2": "dev-custom@dev" (the second way suggested) and it works fine!

Meanwhile I came up with an alternative method that is working as well. In the composer.json of my fork I added an alias pointing to my branch:

"extra": {
    "branch-alias": {
        "dev-master": "2.0.x-dev",
        "dev-custom": "2.0.n-dev"
    }
}

(Worth noticing, in the label 2.0.n-dev n is a random number I just tried)

Then in the composer.json of my yii2-advanced project I used "yiisoft/yii2": "2.0.n.x-dev".

The reason why I need to use "2.0.n.x-dev" instead of "2.0.n-dev" is probably explained here.