Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve composer package circular dependency of external package?

See Github issue, where this question originated.

My package is phpdocumentor/reflection-docblock, it's not a dependency.


I'm trying to update phpdocumentor/reflection-docblock to newer phpunit/phpunit dependency, that started to use the package I update.

There is new circular dependency:

  • (this) phpdocumentor/reflection-docblock package requires phpunit/phpunit
  • phpunit/phpunit requires phpspec/prophecy (since phpunit/phpunit 4.5)
  • phpspec/prophecy requires this phpdocumentor/reflection-docblock (this) package

In abstraction:

  • A needs B
  • B needs C (new one!)
  • C needs A

Before - works

{
    "require-dev": {
        "phpunit/phpunit": "4.4"
    }
}

After - broken

{
    "require-dev": {
        "phpunit/phpunit": "4.5"
    }
}

When I run:

composer update

Composer conflict output:

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

  Problem 1
    - Installation request for phpdocumentor/reflection-docblock dev-phpunit -> satisfiable by phpdocumentor/reflection-docblock[dev-phpunit].
    - phpspec/prophecy v1.3.1 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5].
    - phpunit/phpunit 4.5.0 requires phpspec/prophecy ~1.3.1 -> satisfiable by phpspec/prophecy[v1.3.1].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.1, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.2, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.3, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.4, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.5, dev-phpunit].
    - Installation request for phpunit/phpunit 4.5 -> satisfiable by phpunit/phpunit[4.5.0].

I've tried:

  • minimum-stability: dev
  • aliases "phpunit/phpunit": "4.5 as 4.4"

Any ideas how to approach this?

like image 760
Tomas Votruba Avatar asked Oct 11 '25 17:10

Tomas Votruba


1 Answers

Add

"extra": {
    "branch-alias": {
        "dev-master": "4.x-dev"
    }
}

to composer.json of phpdocumentor/reflection-docblock.

This will allow you to use current master as version 4.x which satisfies requirements

Downside is. You will have to update this section when moving on with versions.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!