Search code examples
laraveldependenciescomposer-phpopen-sourcegit-fork

How to use Laravel fork in project?


Once upon a time I decided to contribute Laravel framework. I forked it, created new branch, wrote feature, then I wanted to test my feature, so I created an empty Laravel project, and here I got stuck.

I changed composer.json like this

    ...
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/trckster/framework"
        }
    ],
    "require": {
        ...
        "laravel/framework": "dev-feat/show-fields-difference-for-similar-results",
        ...
    },
    ...

Then I ran composer update and composer said I'm wrong

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

  Problem 1
    - illuminate/support[v6.0.0, ..., v6.19.1] require php ^7.2 -> your php version (8.0.19) does not satisfy that requirement.
    - illuminate/support[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.0.19) does not satisfy that requirement.
    - illuminate/support[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.0.19) does not satisfy that requirement.
    - Root composer.json requires laravel/framework dev-feat/show-fields-difference-for-similar-results -> satisfiable by laravel/framework[dev-feat/show-fields-difference-for-similar-results].
    - laravel/tinker[v2.7.0, ..., 2.x-dev] require illuminate/support ^6.0|^7.0|^8.0|^9.0 -> satisfiable by illuminate/support[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev].
    - Only one of these can be installed: illuminate/support[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev], laravel/framework[dev-feat/show-fields-difference-for-similar-results]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
    - Root composer.json requires laravel/tinker ^2.7 -> satisfiable by laravel/tinker[v2.7.0, v2.7.1, v2.7.2, 2.x-dev].

It was obvious that problem was in dependencies, but I had no idea what to do with this stuff and finally test my feature.


Solution

  • After a few weeks I returned to this problem and started searching information in the Internet and found useful article, there was described similar problem and way to solve it:

    Now we can adjust our fork’s composer.json requirement and tell it to treat our custom branch as v2.4.5 like so.

    Basically, all I needed to do is change one line in composer.json

    -    "laravel/framework": "dev-feat/show-fields-difference-for-similar-results",
    +    "laravel/framework": "dev-feat/show-fields-difference-for-similar-results as 9.11",
    

    And it worked, composer update downloaded forked version from my github. Hope this self-answered question was helpful!