我想使用Phpspreadsheet包编写脚本。我不是PHP的经验。我试图通过sudo composer需要phpoffice / phpspreadsheet添加对我的脚本的引用。但它不起作用。我收到错误:在stallation失败,删除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.
答案 0 :(得分:21)
所以我应该安装
sudo apt install php-xml
sudo apt install php7.0-gd
sudo apt install php7.0-mbstring
sudo apt install php-zip
答案 1 :(得分:7)
也在运行 composer install/update 或安装新包时添加
--ignore-platform-reqs
在命令的末尾,同时为不同的环境添加/安装成功。
答案 2 :(得分:1)
请阅读错误消息"需要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"
},
答案 3 :(得分:1)
sudo apt安装php-xml
sudo apt安装php7.0-gd
sudo apt安装php7.0-mbstring
sudo apt安装php-zip
答案 4 :(得分:1)
我遇到了同样的问题,我这样做了
composer install --ignore-platform-reqs
答案 5 :(得分:0)
如果您正在使用
$sheet->setAutoFilter();
尝试对此进行评论以进行测试
//$sheet->setAutoFilter();
适合我
答案 6 :(得分:0)
在Centos中:
sudo yum install gd gd-devel php-gd
答案 7 :(得分:0)
错误消息显示未命中。我遇到了同样的问题,可以通过执行此操作来解决。 请阅读错误消息“ requires 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-压缩php7.1-fpm sudo apt安装php-xml php7.1-gd php7.1-dom
答案 8 :(得分:0)
类型
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