Linux composer install 报错

1,697 阅读2分钟

To enable extensions, verify that they are enabled in your .ini files:

问题来源

composer install 第三方包的时候,发生如下错误

**

[root@iZuf6993bfud4lye1gri2xZ zfw]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - lcobucci/jwt is locked to version 4.2.1 and an update of this package was not requested.
    - lcobucci/jwt 4.2.1 requires ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
  Problem 2
    - phpoffice/phpspreadsheet is locked to version 1.24.0 and an update of this package was not requested.
    - phpoffice/phpspreadsheet 1.24.0 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
  Problem 3
    - tijsverkoyen/css-to-inline-styles is locked to version 2.2.4 and an update of this package was not requested.
    - tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
  Problem 4
    - phar-io/manifest is locked to version 2.0.3 and an update of this package was not requested.
    - phar-io/manifest 2.0.3 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
  Problem 5
    - phpunit/php-code-coverage is locked to version 9.2.16 and an update of this package was not requested.
    - phpunit/php-code-coverage 9.2.16 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
  Problem 6
    - phpunit/phpunit is locked to version 9.5.22 and an update of this package was not requested.
    - phpunit/phpunit 9.5.22 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
  Problem 7
    - theseer/tokenizer is locked to version 1.2.1 and an update of this package was not requested.
    - theseer/tokenizer 1.2.1 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
  Problem 8
    - tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
    - laravel/framework v8.83.23 requires tijsverkoyen/css-to-inline-styles ^2.2.2 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.4].
    - laravel/framework is locked to version v8.83.23 and an update of this package was not requested.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/opt/remi/php74/php.ini
    - /etc/opt/remi/php74/php.d/20-bz2.ini
    - /etc/opt/remi/php74/php.d/20-calendar.ini
    - /etc/opt/remi/php74/php.d/20-ctype.ini
    - /etc/opt/remi/php74/php.d/20-curl.ini
    - /etc/opt/remi/php74/php.d/20-exif.ini
    - /etc/opt/remi/php74/php.d/20-fileinfo.ini
    - /etc/opt/remi/php74/php.d/20-ftp.ini
    - /etc/opt/remi/php74/php.d/20-gd.ini
    - /etc/opt/remi/php74/php.d/20-gettext.ini
    - /etc/opt/remi/php74/php.d/20-iconv.ini
    - /etc/opt/remi/php74/php.d/20-json.ini
    - /etc/opt/remi/php74/php.d/20-mbstring.ini
    - /etc/opt/remi/php74/php.d/20-mysqlnd.ini
    - /etc/opt/remi/php74/php.d/20-pdo.ini
    - /etc/opt/remi/php74/php.d/20-phar.ini
    - /etc/opt/remi/php74/php.d/20-sockets.ini
    - /etc/opt/remi/php74/php.d/20-sqlite3.ini
    - /etc/opt/remi/php74/php.d/20-tokenizer.ini
    - /etc/opt/remi/php74/php.d/30-mysqli.ini
    - /etc/opt/remi/php74/php.d/30-pdo_mysql.ini
    - /etc/opt/remi/php74/php.d/30-pdo_sqlite.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-sodium --ignore-platform-req=ext-dom` to temporarily ignore these required extensions.

解决方法

带上引包的时候带上--ignore-platform-reqs

composer install --ignore-platform-reqs

参数说明

--ignore-platform-reqs:  ignore all platform requirements (phphhvmlib-* and ext-*) and force the installation even if the local machine does not fulfill these. See also the platform config option

忽略所有平台要求(php,hhvm,lib- *和ext- *)并强制安装,即使本地计算机不满足这些要求