4

I have php 7.0.29 version installed on my vagrant setup on windows 10.

When I run following command

composer require --dev phpunit/phpunit

I get errors as mentioned

Using version ^6.5 for phpunit/phpunit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
    - Conclusion: don't install phpunit/phpunit 6.5.8
    - Conclusion: don't install phpunit/phpunit 6.5.7
    - Conclusion: don't install phpunit/phpunit 6.5.6
    - Conclusion: don't install phpunit/phpunit 6.5.5
    - Conclusion: don't install phpunit/phpunit 6.5.4
    - Conclusion: don't install phpunit/phpunit 6.5.3
    - Conclusion: don't install phpunit/phpunit 6.5.2
    - Conclusion: don't install phpunit/phpunit 6.5.1
    - phpunit/dbunit 2.0.3 conflicts with phpunit/phpunit[6.5.0].
    - phpunit/phpunit 6.5.0 conflicts with phpunit/dbunit[2.0.3].
    - phpunit/phpunit 6.5.0 conflicts with phpunit/dbunit[2.0.3].
    - Installation request for phpunit/phpunit ^6.5 -> satisfiable by phpunit/phpunit[6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.5.7, 6.5.8].
    - Installation request for phpunit/dbunit (locked at 2.0.3, required as ^2.0) -> satisfiable by phpunit/dbunit[2.0.3].

My composer.json file has following code

{
    "name": "tsawler/acme",
    "authors": [
        {
            "name": "xyz",
            "email": "xyz@example.com"
        }
    ],
    "require": {
        "filp/whoops": "2.0.*",
        "vlucas/phpdotenv": "~1.1",
        "illuminate/database": "5.1.*",
        "altorouter/altorouter": "1.1.0",
        "respect/validation": "~1.0",
        "duncan3dc/blade": "2.2.*",
        "robmorgan/phinx": "^0.4.5",
        "symfony/var-dumper": "^2.7",
        "cocur/slugify": "^1.2",
        "swiftmailer/swiftmailer": "^5.4",
        "kunststube/csrfp": "^0.1.0",
        "sunra/php-simple-html-dom-parser": "v1.5.0",
        "rdlowrey/auryn": "1.1.*",
        "fabpot/goutte": "^3.1"
    },
    "autoload": {
      "psr-4": { "Acme\\": "src/" }
    },
    "require-dev": {
        "phpunit/phpunit": "^5.1",
        "phpunit/php-invoker": "^1.1",
        "phpunit/dbunit": "^2.0"
    }
}

How do I fix it?

Mukesh
  • 7,630
  • 21
  • 105
  • 159
  • Either check if PHP 7.0 is high enough for this repository requirements and if so, try to remove the composer.lock file and install again. – hakre Apr 28 '18 at 14:27
  • @hakre I deleted composer.lock file and tried again but it did not help – Mukesh Apr 28 '18 at 18:05
  • Then it looks like that the packages you require are not compatible to each other. Is there anything special requiring these versions? – hakre Apr 29 '18 at 07:47
  • @hakre I don't think I need specific version. I am following a tutorial and first time using php unit as well as composer. Do you have any suggestion to fix this ? – Mukesh Apr 29 '18 at 19:20
  • Please share the full content of your `composer.json`. – rob006 May 03 '18 at 22:04
  • @rob006 I have updated the question with complete composer.json – Mukesh May 04 '18 at 18:44
  • Why are you manually requiring `phpunit/php-invoker` and `phpunit/dbunit`? Shouldn't `phpunit/phpunit` suffice? – k0pernikus May 07 '18 at 09:47

3 Answers3

7
  • I got this error when trying to upgrade my phpunit by requiring it again. Solution for me was to uninstall phpunit and reinstall it:

          $ composer remove phpunit/phpunit --dev
          $ composer require phpunit/phpunit --dev
    
Shabeer K
  • 1,489
  • 16
  • 23
1

You are requiring old versions of:

"phpunit/php-invoker": "^1.1",
"phpunit/dbunit": "^2.0"

Yet phpunit requires more up to date version of those dependencies as it tells you here:

- phpunit/dbunit 2.0.3 conflicts with phpunit/phpunit[6.5.0].
- phpunit/phpunit 6.5.0 conflicts with phpunit/dbunit[2.0.3].
- phpunit/phpunit 6.5.0 conflicts with phpunit/dbunit[2.0.3]

Only require phpunit/phpunit, instead and let composer handle its dependencies instead of requiring each dependency.

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
1

I've got the same problem. I did

composer remove symfony/phpunit-bridge --dev

after that, I reinstalled it by doing

composer require --dev symfony/phpunit-bridge

and then

php bin/phpunit
Nel
  • 454
  • 5
  • 14