繁体   English   中英

作曲家需要 phpoffice/phpspreadsheet 不起作用

[英]Composer require phpoffice/phpspreadsheet doesn't work

我想使用包 Phpspreadsheet 编写一个脚本。 我没有php经验。 我正在尝试通过 sudo composer require phpoffice/phpspreadsheet 添加对我的脚本的引用。 但它不起作用。 我收到错误消息:安装失败,删除 composer.json....如果不知道它为什么不工作。 任何的想法?

详细错误:

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

Problem 1
- Installation request for phpoffice/phpspreadsheet ^1.0 -> satisfiable by phpoffice/phpspreadsheet[1.0.0].
- phpoffice/phpspreadsheet 1.0.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.

To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mcrypt.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.

所以我应该安装

sudo apt install php-xml

sudo apt install php7.0-gd

sudo apt install php7.0-mbstring

sudo apt install php-zip

也在运行 composer install/update 或安装新包时添加

--ignore-platform-reqs

在命令末尾,同时为不同环境成功添加/安装。

在 Centos 中:

须藤 yum 安装 gd gd-devel php-gd

sudo apt 安装 php-xml

sudo apt 安装 php7.0-gd

sudo apt 安装 php7.0-mbstring

sudo apt 安装 php-zip

我有同样的问题,我通过这样做来解决它

composer install --ignore-platform-reqs

请阅读错误消息“需要 ext-dom”。 它抱怨缺少软件包或在这种情况下是 php 扩展。 通常,当您无法安装某个软件包时,您可以在其 composer.json 中查看所需的软件包以查看完整列表。

phpoffice(在本例中为 1.1.0)需要以下内容:

   "require": {
        "php": "^5.6|^7.0",
        "ext-ctype": "*",
        "ext-dom": "*",
        "ext-gd": "*",
        "ext-iconv": "*",
        "ext-libxml": "*",
        "ext-mbstring": "*",
        "ext-SimpleXML": "*",
        "ext-xml": "*",
        "ext-xmlreader": "*",
        "ext-xmlwriter": "*",
        "ext-zip": "*",
        "ext-zlib": "*",
        "psr/simple-cache": "^1.0"
    },
    "require-dev": {
        "tecnickcom/tcpdf": "^6.2",
        "squizlabs/php_codesniffer": "^2.7",
        "phpunit/phpunit": "^5.7",
        "dompdf/dompdf": "^0.8.0",
        "mpdf/mpdf": "^7.0.0",
        "jpgraph/jpgraph": "^4.0",
        "friendsofphp/php-cs-fixer": "@stable"
    },

错误信息显示未命中。 我有同样的问题,通过这样做来解决它。 请阅读错误消息“需要 ext-dom”。

请安装php7.1-dom

就我而言,PHP 低于 7.1 是我所做的并且现在正在工作。

sudo apt-get install php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7. 1-fpm sudo apt install php-xml php7.1-gd php7.1-dom

如果你正在使用

$sheet->setAutoFilter(); 

尝试评论这个来测试

//$sheet->setAutoFilter();

为我工作

类型

 php -v

如果 php7 类型

sudo apt install php-xml
sudo apt install php7.0-gd
sudo apt install php7.0-mbstring
sudo apt install php-zip

如果 php8 类型

sudo apt install php-xml
sudo apt install php8.0-gd
sudo apt install php8.0-mbstring
sudo apt install php-zip

我遇到了同样的问题,我使用命令composer install --ignore-platform-reqs解决了它

如果您是 Arch 用户,请编辑/etc/php74/php.ini或您使用的任何版本。 确保已安装扩展并且取消注释 gd 扩展。

extension=gd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM