Composer安装Yii2 Highcharts Widget失败的问题求助
Yii2 Highcharts Widget Composer安装失败解决指南
安装命令
composer require miloschuman/yii2-highcharts-widget
问题详情
执行安装命令后出现以下错误:
:\xampp\htdocs\lesco>composer require miloschuman/yii2-highcharts-widget The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.3.0"). You may need to run composer update with the "--no-plugins" option. ./composer.json has been updated The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.3.0"). You may need to run composer update with the "--no-plugins" option. Running composer update miloschuman/yii2-highcharts-widget Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1 - phpoffice/phpspreadsheet is locked to version 1.10.1 and an update of this package was not requested. - phpoffice/phpspreadsheet 1.10.1 requires php ^7.1 -> your php version (8.0.25) does not satisfy that requirement. Problem 2 - codeception/base is locked to version 2.5.x-dev and an update of this package was not requested. - codeception/base 2.5.x-dev requires php >=5.6.0 <8.0 -> your php version (8.0.25) does not satisfy that requirement. Problem 3 - symfony/var-dumper v4.2.0 requires php ^7.1.3 -> your php version (8.0.25) does not satisfy that requirement. - luoxiaojun1992/yii2-tinker dev-master requires symfony/var-dumper 4.2.0 -> satisfiable by symfony/var-dumper[v4.2.0]. - luoxiaojun1992/yii2-tinker is locked to version dev-master and an update of this package was not requested. You can also try re-running composer require with an explicit version constraint, e.g. "composer require miloschuman/yii2-highcharts-widget:*" to figure out if any version is installable, or "composer require miloschuman/yii2-highcharts-widget:^2.1" if you know which you need. Installation failed, reverting ./composer.json and ./composer.lock to their original content.
当前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": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": "~2.0.13", "yiisoft/yii2-bootstrap": "~2.0.0", "yiisoft/yii2-swiftmailer": "~2.0.0", "luoxiaojun1992/yii2-tinker": "*", "kartik-v/yii2-grid": "@dev", "kartik-v/yii2-widget-select2": "@dev", "kartik-v/yii2-mpdf": "dev-master", "moonlandsoft/yii2-phpexcel": "*", "nirvana-msu/yii2-showloading": "1.0.*@dev", "kartik-v/yii2-krajee-base": "^2.0", "kartik-v/yii2-widget-spinner": "@dev", "edwinhaq/yii2-simple-loading": "*", "c006/yii2-submit-spinner": "*", "kartik-v/yii2-detail-view": "*", "fedemotta/yii2-cronjob": "*", "kartik-v/yii2-widget-datetimepicker": "*", "kartik-v/yii2-date-range": "dev-master", "phpoffice/phpspreadsheet": "^1.2", "linslin/yii2-curl": "*", "kartik-v/yii2-widget-fileinput": "@dev", "kartik-v/yii2-dialog": "*", "google/apiclient": "^2.0", "delight-im/str": "^2.4", "mongosoft/yii2-soap-client": "dev-master", "kartik-v/yii2-export": "@dev", "ext-json": "*", "ext-curl": "*" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", "yiisoft/yii2-gii": "~2.0.0", "yiisoft/yii2-faker": "~2.0.0", "codeception/base": "^2.2.3", "codeception/verify": "~0.3.1" }, "config": { "process-timeout": 1800, "fxp-asset": { "enabled": false } }, "extra": { "asset-installer-paths": { "npm-asset-library": "vendor/npm", "bower-asset-library": "vendor/bower" } }, "scripts": { "post-install-cmd": "php init --env=Development --overwrite=n" }, "autoload": { "psr-4": { "kartik\\spinner\\": "", "nirvana\\showloading\\": "" } }, "repositories": [{ "type": "composer", "url": "https://asset-packagist.org" }] }
已尝试的方法
执行composer install --ignore-platform-reqs后出现新错误:
The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.3.0"). You may need to run composer update with the "--no-plugins" option. Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`. Your lock file does not contain a compatible set of packages. Please run composer update. Problem 1 - kartik-v/yii2-widget-select2 is locked to version dev-master and an update of this package was not requested. - kartik-v/yii2-widget-select2 dev-master requires select2/select2 >=4.0 -> found select2/select2[dev-master] but it does not match the constraint. Problem 2 - codeception/phpunit-wrapper is locked to version 7.8.0 and an update of this package was not requested. - codeception/phpunit-wrapper 7.8.0 requires sebastian/diff ^3.0 -> found sebastian/diff[dev-master, 4.0.x-dev (alias of dev-master)] but it does not match the constraint. Problem 3 - phpunit/php-code-coverage is locked to version 6.1.4 and an update of this package was not requested. - phpunit/php-code-coverage 6.1.4 requires phpunit/php-file-iterator ^2.0 -> found phpunit/php-file-iterator[dev-master, 3.0.x-dev (alias of dev-master)] but it does not match the constraint. Problem 4 - phpunit/phpunit is locked to version 7.5.x-dev and an update of this package was not requested. - phpunit/phpunit 7.5.x-dev requires phpunit/php-file-iterator ^2.0.1 -> found phpunit/php-file-iterator[dev-master, 3.0.x-dev (alias of dev-master)] but it does not match the constraint. Problem 5 - sebastian/comparator is locked to version 3.0.2 and an update of this package was not requested. - sebastian/comparator 3.0.2 requires sebastian/diff ^3.0 -> found sebastian/diff[dev-master, 4.0.x-dev (alias of dev-master)] but it does not match the constraint. Problem 6 - sebastian/exporter is locked to version 3.1.2 and an update of this package was not requested. - sebastian/exporter 3.1.2 requires sebastian/recursion-context ^3.0 -> found sebastian/recursion-context[dev-master, 4.0.x-dev (alias of dev-master)] but it does not match the constraint. Problem 7 - sebastian/object-enumerator is locked to version 3.0.3 and an update of this package was not requested. - sebastian/object-enumerator 3.0.3 requires sebastian/object-reflector ^1.1.1 -> found sebastian/object-reflector[dev-master, 2.0.x-dev (alias of dev-master)] but it does not match the constraint. Problem 8 - kartik-v/yii2-widget-select2 dev-master requires select2/select2 >=4.0 -> found select2/select2[dev-master] but it does not match the constraint. - kartik-v/yii2-widget-select2 2.1.x-dev is an alias of kartik-v/yii2-widget-select2 dev-master and thus requires it to be installed too. - kartik-v/yii2-widget-select2 is locked to version 2.1.x-dev and an update of this package was not requested. Use the option --with-all-dependencies (-W) to allow upgrades, downgrades, and removals for packages currently locked to specific versions.
解决方案
1. 修复依赖版本兼容性
编辑composer.json,更新以下内容以适配PHP8.0:
- 将
php版本约束改为>=7.4 - 升级
phpoffice/phpspreadsheet到^1.28(支持PHP8) - 升级
codeception/base到^4.0,codeception/verify到^2.0(支持PHP8) - 添加
yiisoft/yii2-composer:^2.0(兼容Composer2) - 若
luoxiaojun1992/yii2-tinker无PHP8兼容版本,可暂时移除该依赖(或寻找替代包)
修改后的关键片段:
"require": { "php": ">=7.4", ... "phpoffice/phpspreadsheet": "^1.28", "yiisoft/yii2-composer": "^2.0", // 移除或替换luoxiaojun1992/yii2-tinker // "luoxiaojun1992/yii2-tinker": "*", ... }, "require-dev": { ... "codeception/base": "^4.0", "codeception/verify": "^2.0", ... }
2. 处理Composer插件问题
先安装兼容的yii2-composer插件,跳过旧插件:
composer require yiisoft/yii2-composer:^2.0 --no-plugins
3. 更新所有依赖并安装目标包
允许更新所有关联依赖,确保版本兼容:
composer update -W --no-plugins
然后安装Yii2 Highcharts Widget:
composer require miloschuman/yii2-highcharts-widget --no-plugins
4. 临时解决方案(谨慎使用)
若部分依赖无法升级,可临时忽略平台要求(不推荐生产环境):
composer require miloschuman/yii2-highcharts-widget --ignore-platform-reqs --no-plugins
内容的提问来源于stack exchange,提问作者Moeez
相关产品推荐
相关产品推荐

