解决 composer 安装 phpunit 失败问题

更新日期: 2018-07-30 阅读次数: 11407 分类: PHP

$ composer require --dev phpunit/phpunit            
                                                                                                                          
Using version ^7.2 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 7.2.7                                                                                                                           
    - Conclusion: don't install phpunit/phpunit 7.2.6                                                                                                                            
    - Conclusion: don't install phpunit/phpunit 7.2.5          
    - Conclusion: don't install phpunit/phpunit 7.2.4                     
    - Conclusion: don't install phpunit/phpunit 7.2.3                                  
    - Conclusion: don't install phpunit/phpunit 7.2.2                       
    - Conclusion: don't install phpunit/phpunit 7.2.1      
    - phpunit/phpunit 7.2.0 conflicts with phpunit/phpunit-mock-objects[5.0.6].
    - phpunit/phpunit 7.2.0 conflicts with phpunit/phpunit-mock-objects[5.0.6].
    - phpunit/phpunit 7.2.0 conflicts with phpunit/phpunit-mock-objects[5.0.6].
    - Installation request for phpunit/phpunit ^7.2 -> satisfiable by phpunit/phpunit[7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7].
    - Installation request for phpunit/phpunit-mock-objects (locked at 5.0.6) -> satisfiable by phpunit/phpunit-mock-objects[5.0.6].
                                                                 
                                                                
Installation failed, reverting ./composer.json to its original content.    

查看了 composer.json, 这时我才意识到原来项目中已经安装了 phpunit 6.0, 而我运行的命令会安装最新版的 phpunit 7.2.

卸载重装 phpunit 即可

$ composer remove phpunit/phpunit --dev
$ composer require phpunit/phpunit --dev

微信关注我哦 👍

大象工具微信公众号

我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式