php Composer 需要 phpoffice/phpspreadsheet 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48240726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:38:44  来源:igfitidea点击:

Composer require phpoffice/phpspreadsheet doesn't work

phpexcelphpspreadsheet

提问by MrScf

I want to write a Script using the package Phpspreadsheet. I am not experience in php. I am trying to add the reference to my script through sudo composer require phpoffice/phpspreadsheet. But it doesn't work. I am getting the error: In stallation failed, deleting composer.json....If have no idea why it is not working. Any idea?

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

Detailed Error:

详细错误:

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.

回答by MrScf

So I should install

所以我应该安装

sudo apt install php-xml

sudo apt install php-xml

sudo apt install php7.0-gd

sudo apt install php7.0-gd

sudo apt install php7.0-mbstring

sudo apt install php7.0-mbstring

sudo apt install php-zip

sudo apt install php-zip

回答by jhoskins98

Please read the error message "requires ext-dom". It is complaining about a missing package or in this case php extension. Generally, when you can't install a package you can look at the required packages in its composer.json to see the complete list.

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

phpoffice (1.1.0 in this case) requires the following:

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"
    },

回答by Ali Shahnazi

In Centos:

在 Centos 中:

sudo yum install gd gd-devel php-gd

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

回答by Powen Ko

The error message display miss. I had the same problem, fix it by doing this. Please read the error message "requires ext-dom".

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

please install php7.1-dom

请安装php7.1-dom

in my case, PHP is 7.1 below is I did and working now.

就我而言,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

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

回答by Mauricio Paz

if you are using

如果你正在使用

$sheet->setAutoFilter(); 

try comment this to test

尝试评论这个来测试

//$sheet->setAutoFilter();

works for me

为我工作