[英]Composer require phpoffice/phpspreadsheet doesn't work
I want to write a Script using the package Phpspreadsheet.我想使用包 Phpspreadsheet 编写一个脚本。 I am not experience in php.
我没有php经验。 I am trying to add the reference to my script through sudo composer require phpoffice/phpspreadsheet.
我正在尝试通过 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.
我收到错误消息:安装失败,删除 composer.json....如果不知道它为什么不工作。 Any idea?
任何的想法?
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.
所以我应该安装
sudo apt install php-xml
sudo apt install php7.0-gd
sudo apt install php7.0-mbstring
sudo apt install php-zip
also while running composer install/update or install new package adds也在运行 composer install/update 或安装新包时添加
--ignore-platform-reqs
at the end of command, while add/install successfully for different environments.在命令末尾,同时为不同环境成功添加/安装。
In Centos:在 Centos 中:
sudo yum install gd gd-devel php-gd须藤 yum 安装 gd gd-devel php-gd
sudo apt install php-xml sudo apt 安装 php-xml
sudo apt install php7.0-gd sudo apt 安装 php7.0-gd
sudo apt install php7.0-mbstring sudo apt 安装 php7.0-mbstring
sudo apt install php-zip sudo apt 安装 php-zip
我有同样的问题,我通过这样做来解决它
composer install --ignore-platform-reqs
Please read the error message "requires ext-dom".请阅读错误消息“需要 ext-dom”。 It is complaining about a missing package or in this case php extension.
它抱怨缺少软件包或在这种情况下是 php 扩展。 Generally, when you can't install a package you can look at the required packages in its composer.json to see the complete list.
通常,当您无法安装某个软件包时,您可以在其 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"
},
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
if you are using如果你正在使用
$sheet->setAutoFilter();
try comment this to test尝试评论这个来测试
//$sheet->setAutoFilter();
works for me为我工作
type类型
php -v
if php7 type如果 php7 类型
sudo apt install php-xml
sudo apt install php7.0-gd
sudo apt install php7.0-mbstring
sudo apt install php-zip
if php8 type如果 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
解决了它
If you are arch user edit /etc/php74/php.ini
or whichever version you use.如果您是 Arch 用户,请编辑
/etc/php74/php.ini
或您使用的任何版本。 Makes sure the extension is installed and the gd extension is uncommented.确保已安装扩展并且取消注释 gd 扩展。
extension=gd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.